0

In the example below, I store text into three variables (\subTa, \subTb, \subTc), and then use these variables to set the subsection, set the frametitle, and display text on each slide, all using \only as shown in the example below.

\documentclass[pdf]{beamer}
\begin{document}

\def\subTa{$1^{st}$ Step}
\def\subTb{$2^{nd}$ Step}
\def\subTc{$3^{rd}$ Step}

\section{Solution}
\begin{frame}
    \only<+>{\subsection{\subTa}}
    \only<+>{\subsection{\subTb}}
    \only<+>{\subsection{\subTc}}
    \frametitle{\insertsection...\only<1>{\subTa}\only<2>{\subTb}\only<3>{\subTc}}
    \only<1>{\subTa:}
    \only<2>{\subTb:}
    \only<3>{\subTc:}
    \begin{align*}
        \uncover<1->{2x-c&=2}
        \uncover<2->{\\ 2x&=2+c}
        \uncover<3->{\\ x&=1+0.5c}
    \end{align*}
\end{frame}
\end{document}

Is there a way to do this where the text I stored in the three variables is stored in an array (something like \def\subTarray{{"$1^{st}$ Step","$2^{nd}$ Step,"$3^{rd}$ Step"}}), and then the subsection, frametitle, and text is set by looping through the array? Separate loops will be needed for at least the text and the frametitle/subsections, but using a single array would be desirable. If it is not possible to have one array for all three parts (frametitle, subsection, and text), examples of how to use an array and loop for the parts individually would also be appreciated.

I tried solutions to similar questions (pgf-tikz-how-to-store-strings-in-array, loop-for-includegraphics, and this array-indexing-does-not-work-for-the-node-label), and I could get the text part to work using an array, but not in a loop. And I did not have much luck with the frametitle or subsections.

2

Just let beamer do it for you:

\documentclass{beamer}

\usepackage[super]{nth} 

\makeatletter
   \def\c@slideinframe{\beamer@slideinframe}   
   \def\beamerslideinframe{\beamer@slideinframe} 
\makeatother

\begin{document}
\section{Solution}
\begin{frame}
    \frametitle{\insertsection{} \nth{\beamerslideinframe} Step}
    \begin{align*}
        \uncover<1->{2x-c&=2}
        \uncover<2->{\\ 2x&=2+c}
        \uncover<3->{\\ x&=1+0.5c}
    \end{align*}
\end{frame}
\end{document}

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.