josephwright / beamer

A LaTeX class for producing presentations and slides
Other
1.35k stars 139 forks source link

Resumable enumerate #847

Open jspitz opened 1 year ago

jspitz commented 1 year ago

A frequent request we get with LyX is that people want a way to resume an enumeration on a later slide. As beamer does not work with enumitem, we provide a "module" (addon) that patches beamer's and beamerarticle's enumerate and adds a new resenumerate environment, like so:

    \newif\ifenumresume\enumresumefalse
    \newcounter{saveenumi}
    \newcommand*\saveenumvalue{\ifnum\@listdepth<2\setcounter{saveenumi}{\value{enumi}}\fi}
    \newcommand*\restoreenumvalue{\ifnum\@listdepth<2\setcounter{enumi}{\value{saveenumi}}\fi}
    \only<presentation>{\resetcounteronoverlays{saveenumi}}
    \usepackage{etoolbox}
    \AtEndEnvironment{enumerate}{\saveenumvalue}
    \let\resenumerate\enumerate
    \let\endresenumerate\endenumerate
    \AtBeginEnvironment{resenumerate}{\enumresumetrue}
    \AtEndEnvironment{resenumerate}{\enumresumefalse\saveenumvalue}
    \apptocmd{\beamer@enum@}{\ifenumresume\restoreenumvalue\fi}{}{}
    \AtBeginDocument{%
      \only<article>{%
      \makeatletter
      \apptocmd{\@enum@}{\ifenumresume\restoreenumvalue\fi}{}{}
      \makeatother
      }
    }

Of course, this is rather kludgy, so I was wondering whether it would make sense to implement a resume option of some sort in beamer(article) directly. I am not sure about the best syntax (new/starred environment? special mini-template syntax? environment option?), but the implementation itself strikes me pretty straightforward.