\includeonly 명령이 생략된 장에 대한 장 카운터를 \stepcounter하지 않는 이유는 무엇입니까?

\includeonly 명령이 생략된 장에 대한 장 카운터를 \stepcounter하지 않는 이유는 무엇입니까?

\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가 후속 장의 올바른 번호에서 시작하기 위해 건너뛰는 페이지 수를 결정하기 위해 2장의 내용을 검토하는 경우 장 카운터를 확인/단계화하지 않는 이유가 있습니까? 아니면 내가 잘못 사용하고 있거나 뭔가를 이해하지 못했습니까?

답변1

LaTeX는 포함되지 않은 파일을 전혀 열지 않고 해당 .aux파일만 엽니다. 모든 라텍스 카운터의 값은 포함된 각 파일의 aux 파일에 저장됩니다.

따라서 그렇게 하면 \includeonly{chaptertwo}선언 \include{chapterone}된 모든 라텍스 카운터를 처리가 끝날 때의 값으로 설정합니다.chapterone.tex 저번에 포함됐던.

따라서 정기적으로 전체 문서를 처리하지 않고 \includeonly각 지점에 저장된 값이 \include올바른 값에 더 가까워지도록 해야 합니다.

관련 정보