
我嘗試按照說明在不同文件中執行 a\ref
操作失敗。\label
最終,這將針對不同資料夾中的檔案;我有一個資料夾用於存放安裝指南文件,另一個資料夾用於存放系統管理指南文件。
我嘗試了兩種不同的方法,如下面的(1)和(2)所述。我的程式碼在(3)和(4)。
(1) 嘗試使用的結果\input{../TestFolder/outiedoc.aux}
:章節號已正確插入。但是,會出現斜體的額外垃圾:「writefiletoc」和「writefilelofwritefilelot」。一旦我在真實文件而不是小測試文件中使用該命令,我是否應該期望這些消失?
(2) 使用結果
\usepackage{xr}
\externaldocument{../Testfolder/outiedoc} :
沒有垃圾,但我明白了?而不是章節號。
(3) 這是我在 outiedoc 中的內容:
\documentclass{book}
\begin{document}
\chapter{The Far Shore}\label{ch:outieRef}
This is the first chapter of the book.
\end{document}
(4) 這是我在呼叫文件中的內容,除了上面 (1) 和 (2) 中的行之間的交替之外:
\documentclass{book}
\begin{document}
You can find what you are looking for in chapter~\ref{ch:outieRef}
\end{document}
答案1
您必須在呼叫文件中使用\usepackage{xr}
and ,例如:\externaldocument{outiedoc}
maindoc.tex
\documentclass{book}
\usepackage{xr}
\externaldocument{outiedoc}
\begin{document}
You can find what you are looking for in chapter~\ref{ch:outieRef}
\end{document}
並且在outiedoc.tex
\documentclass{book}
\begin{document}
\chapter{The Far Shore}\label{ch:outieRef}
This is the first chapter of the book.
\end{document}
請編譯這兩個檔案兩次,最好outiedoc.tex
先編譯,然後編譯maindoc.tex
.