1

I use beamer to create complex animations of program execution, where multiple parts change at each step. The final animation has 30 to 40 steps. Here is a simplified MWE:

\begin{document}
\begin{frame}
  \only<1-3>{Some initial text}
  \begin{columns}
    \begin{column}{.3\linewidth}
      \uncover<8>{
        \begin{block}{Part 1}
          \uncover<9>{A}
          \uncover<11>{B}
          \uncover<8>{C}
          \uncover<10>{D}
        \end{block}
      }
    \end{column}
    \begin{column}{.3\linewidth}
      \uncover<4-7>{
        \begin{block}{Part 2}
          \uncover<4>{E}
          \uncover<7>{F}
          \uncover<5>{G}
          \uncover<6>{H}
        \end{block}
      }
    \end{column}
  \end{columns}
\end{frame}
\end{document}

Using numbers in overlay specifications is a nightmare, because any change requires renumbering everything. Using relative specifications is worse, because the order in the LaTeX file isn't the order in which things appear on screen.

The best I've found is using lualatex:

\documentclass{beamer}
\usepackage{luacode}

\begin{luacode*}
first = 4;

part2_first = first;
part2_E = part2_first;
part2_G = part2_E + 1;
part2_H = part2_G + 1;
part2_F = part2_H + 1;
part2 = {part2_first, part2_F};

part1_first = part2[2] + 1;
part1_C = part1_first;
part1_A = part1_C + 1;
part1_D = part1_A + 1;
part1_B = part1_D + 1;
part1 = {part1_first, part1_B};

function num(a) tex.sprint(tostring(a)); end
function range(a) num(a[1]); tex.sprint("-"); num(a[2]); end
\end{luacode*}

\begin{document}
\begin{frame}
\only<1-3>{Some initial text}
\begin{columns}
  \begin{column}{.3\linewidth}
    \uncover<\directlua{range(part1)}>{
      \begin{block}{Part 1}
        \uncover<\directlua{num(part1_A)}>{A}
        \uncover<\directlua{num(part1_B)}>{B}
        \uncover<\directlua{num(part1_C)}>{C}
        \uncover<\directlua{num(part1_D)}>{D}
      \end{block}
    }
  \end{column}
  \begin{column}{.3\linewidth}
    \uncover<\directlua{range(part2)}>{
      \begin{block}{Part 2}
        \uncover<\directlua{num(part2_E)}>{E}
        \uncover<\directlua{num(part2_F)}>{F}
        \uncover<\directlua{num(part2_G)}>{G}
        \uncover<\directlua{num(part2_H)}>{H}
      \end{block}
    }
  \end{column}
\end{columns}
\end{frame}
\end{document}

I'm relatively happy with this solution, but I wonder if there's a native solution that would allow me to share my documents with users of other engines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.