0

In Beamer, I need to make parts of text and/or pictures appear periodically in a loop, each part having a different beginning and end within this loop.

This is the kind of code I normally use.

\uncover<5-8,17-20,29-32>{First,} \uncover<7-14,19-26,31-38>{second.}

I would like to parameterize the values, so that the above code looks something like this:

\def\startLoop{4}
\def\nLoop{12}
\def\startA{1}
\def\stopA{4}
\def\startB{3}
\def\stopB{10}

\uncover<{\startLoop+\startA} - {\startLoop+\stopA} , {\startLoop+\startA+\nLoop} - {\startLoop+\stopA+\nLoop}, {\startLoop+\startA+2*\nLoop} - {\startLoop+\stopA+2*\nLoop}>{First,}  \uncover<{\startLoop+\startB} - {\startLoop+\stopB} , {\startLoop+\startB+\nLoop} - {\startLoop+\stopB+\nLoop}, {\startLoop+\startB+2*\nLoop} - {\startLoop+\stopB+2*\nLoop}>{second.}

Is there a way to get calculated uncover?

0

2 Answers 2

3

We can prepare the argument at expand processor level by \expanded eTeX primitive and then run \uncover macro. Use \euncover instead \uncover, it means "evaluated uncover".

\def\startLoop{4}
\def\nLoop{12}
\def\startA{1}
\def\stopA{4}
\def\startB{3}
\def\stopB{10}

\def\euncover<#1>{\expandafter\uncover\expanded{<\euncoverA#1\end>}}
\def\euncoverA#1#2{\the\numexpr#1\relax
   \ifx\end#2\else #2\expandafter\euncoverA\fi}

\euncover<{\startLoop+\startA} - {\startLoop+\stopA} , {\startLoop+\startA+\nLoop} - {\startLoop+\stopA+\nLoop}, {\startLoop+\startA+2*\nLoop} - {\startLoop+\stopA+2*\nLoop}>{First,}
\euncover<{\startLoop+\startB} - {\startLoop+\stopB} , {\startLoop+\startB+\nLoop} - {\startLoop+\stopB+\nLoop}, {\startLoop+\startB+2*\nLoop} - {\startLoop+\stopB+2*\nLoop}>{second.}
1
  • 1
    Thanks for the answer! It worked for me.
    – NCrown
    Mar 26, 2023 at 20:57
0

I would calculate the values before the uncover macro, e.g.

\documentclass{beamer}

\newcounter{counta}
\newcounter{countb}

\begin{document}
    
\begin{frame}
  \def\startLoop{4}
  \def\nLoop{12}
  \def\startA{1}
  \def\stopA{4}
  \def\startB{3}
  \def\stopB{10}
  
  \setcounter{counta}{\numexpr\startLoop+\startA}
  \setcounter{countb}{\numexpr\startLoop+\stopA}

  \uncover<\thecounta-\thecountb>{second.}
  
\end{frame} 
    
\end{document}
2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .