未编译部分的引用

未编译部分的引用

我正在使用 latex 撰写论文,并且对各个章节使用了不同的文件,然后使用 \input 命令将其插入到主文件中。

有时,我只需要编译 1 章(将其发送给读者,或快速查看我所做的修改)。为此,我会注释/取消注释相关的“输入”命令。

但我想在编译的章节中保留对未编译章节(部分、图表、表格等)的交叉引用。如果我先编译整个文档,是否可以在避免破坏旧目录文件的情况下保留交叉引用,是这样的吗?

我正在使用 cleverref,但我不知道它对当前问题是否有用。

MWE 不是很有用,但它可以如下

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{cleveref}

\begin{document}

%\section{Uncompiled section}\label{thelabel}
%Hello world!

\section{Compiled section}
See \cref{thelabel} to get the Hello World.

\end{document}

答案1

使用\include命令集。例如:

\documentclass{report}
\includeonly{chap1,chap3} % only process chap1.tex and chap3.tex
\begin{document}
\include{chap1}    % input chap1.tex
\include{chap2}    % input chap2.tex
\include{chap3}    % input chap3.tex
\include{chap4}    % input chap4.tex
\end{document}

这将仅处理 chap1.tex 和 chap3.tex,但将保留所有对先前包含的文件的交叉引用。要处理全部文件,请注释掉该\includeonly宏。

相关内容