[Tex/LaTex] Beamer theorem numbering issue

beamernumbering

I have a beamer presentation containing slides for multiple lectures in a single file. Exercises in the slides should be number continuously from the first lecture to the last. So lecture 1 ends with exercise 10, lecture 2 starts with exercise 11 and so on.

When I use \includeonlyframes to make a presentation for a particular lecture it always starts numbering from one again. So, lecture 2 starts again from 1, rather then 11 I would like to see.

It appears that \includeonlyframes doesn't read frames that are not included at all.
Is there a way to make it read all frames and output the right ones, but preserve the numbering in the process?

Best Answer

It appears that \includeonlyframes isn't designed to read all the frames. From the Beamer User Guide, Section 4.3.3 (Ways of Improving Compilation Speed):

This command behaves a little bit like the \includeonly command: Only the frames mentioned in the list are included.

(emphasis mine). Only the section and subsection commands are still executed, for getting correct navigation bars. Since \includeonlyframes is a way to improve the compilation speed, it shouldn't read the contents of the frames. Of course it would be nice to have a version that does it nonetheless ...

I see only one simple way out of your problem: add something like \setcounter{exercise}{10} before your frames for lecture 2, where 10 should be the last exercise from lecture 1. Here's an example:

\documentclass{beamer}
\setbeamertemplate{theorems}[numbered]
\includeonlyframes{t2}
\begin{document}
\begin{frame}[label=t1]
\begin{theorem}
First theorem
\end{theorem}
\end{frame}
\setcounter{theorem}{1}
\begin{frame}[label=t2]
\begin{theorem}
Second theorem
\end{theorem}
\end{frame}
\end{document}

By the way, it would be good if you include an MWE in your next question; it took me some time to write the above code since I didn't know about \setbeamertemplate{theorems}[numbered] before.

Related Question