
我非常喜歡這個\includeonly
命令,它可以在僅列印特定章節的同時保持頁數完整。但我想知道為什麼章節計數器沒有出現在這樣的場景中:
\documentclass{report}
\usepackage{filecontents}
\begin{filecontents}{chapterone.tex}
\chapter{First Title}
Text
\end{filecontents}
\begin{filecontents}{chaptertwo.tex}
\chapter{Second Title}
Text
\end{filecontents}
\begin{filecontents}{chapterthree.tex}
\chapter{Third Title}
Text
\end{filecontents}
\includeonly{chapterone,chapterthree}
\begin{document}
\include{chapterone}
\include{chaptertwo}
%\stepcounter{chapter} % I have to manually step it here to get the right chapter number for three
\include{chapterthree}
\end{document}
如果 LaTeX 遍歷第二章的內容來確定要跳過多少頁,以便從後續章節的正確編號開始,那麼它是否有理由不檢查/步進章節計數器?還是我使用不正確或不理解某些東西?
答案1
LaTeX 根本不打開未包含的文件,它只是打開它們的.aux
文件。所有 Latex 計數器的值都保存在每個包含檔案的 aux 檔案中。
因此,如果您\includeonly{chaptertwo}
這樣做\include{chapterone}
,則將每個聲明的乳膠計數器設為處理結束時的值chapterone.tex
上次包含的內容。
因此,您應該定期處理整個文檔,\includeonly
以便每個\include
點保存的值更接近正確的值。