beamer
beamer copied to clipboard
Wrong numbering of TOC with \includeonly
I am trying to split my document in smaller parts, but doing this results in a wrong numbering of the table of contents with \includeonly switched on.
I have three little documents that demonstrate the issue. The main document:
\documentclass{beamer}
\usetheme{Warsaw}
\includeonly{beamer_include_2}
\begin{document}
\include{beamer_include_1}
\include{beamer_include_2}
\end{document}
The first include:
\section{My Section (1)}
\begin{frame}
\tableofcontents
\end{frame}
\section{My Section (2)}
\begin{frame}
\tableofcontents
\end{frame}
and the second include:
\section{My Section (3)}
\begin{frame}
\tableofcontents
\end{frame}
\section{My Section (4)}
\begin{frame}
\tableofcontents
\end{frame}
This is the result with \includeonly switched on:
This is the result with \includeonly switched off (as expected):
I cannot reproduce the same problem with your MWE: all is well in my compilation result. Additional information might be helpful for solving problems, including:
- TeX distribution version (MiKTeX, TeX Live, MacTeX, etc) and
beamer
version; - Intermediate files, mainly
.aux
and.toc
.
I can reproduce this if I first compile the whole document and only then add \includeonly{}
.
To get rid if the remains of the previous toc, delete all the auxiliary files when you switch from the full document to the one with \includeonly{}
.
FYI: if you let beamer do the work and use \includeonlylecture{}
the toc will update automatically if you switch from one mode to the other
\documentclass{beamer}
\usetheme{Warsaw}
\begin{filecontents*}[overwrite]{beamer_include_1}
\lecture{lecture 1}{lec1}
\section{My Section (1)}
\begin{frame}
\tableofcontents
\end{frame}
\section{My Section (2)}
\begin{frame}
\tableofcontents
\end{frame}
\end{filecontents*}
\begin{filecontents*}[overwrite]{beamer_include_2}
\lecture{lecture 2}{lec2}
\section{My Section (3)}
\begin{frame}
\tableofcontents
\end{frame}
\section{My Section (4)}
\begin{frame}
\tableofcontents
\end{frame}
\end{filecontents*}
\includeonlylecture{lec2}
\begin{document}
\include{beamer_include_1}
\include{beamer_include_2}
\end{document}
Thank you for the quick answer!
I am using:
Ubuntu 18.04.3 LTS texstudio 2.12.6
preview-latex-style/bionic,bionic,now 11.91-1ubuntu1 all
texlive-latex-base/bionic,bionic,now 2017.20180305-1 all
texlive-latex-base-doc/bionic,bionic,now 2017.20180305-1 all
texlive-latex-extra/bionic,bionic,now 2017.20180305-2 all
texlive-latex-extra-doc/bionic,bionic,now 2017.20180305-2 all
texlive-latex-recommended/bionic,bionic,now 2017.20180305-1 all
texlive-latex-recommended-doc/bionic,bionic,now 2017.20180305-1 all
Sorry I do not know where to find the beamer version.
When I follow your suggestion, and delete the aux files, the toc contains only the sections of the included documents. In this case 2 and not 4.
I am using the combination of \tableofcontents and \includeonly in article documents. When I include only a part of the document, the toc contains the sections of the whole document. An example:
\documentclass{article}
\includeonly{doc_include_2}
\begin{document}
\tableofcontents
\include{doc_include_1}
\include{doc_include_2}
\end{document}
with
\section{My section 1}
This is a section.
\section{My section 2}
This is a section.
and
\section{My section 3}
This is a section.
\section{My section 4}
This is a section.
Compile the whole document and then include only the second file and compile it again. Then the toc is complete:
But the document contains only the included sections:
I do not know if this is intended but it is very useful. I can handout only chapters of my document, but the chapters have the correct numbering and have the complete toc.