使用多層嵌套檔案定義相同的 \label 兩次

使用多層嵌套檔案定義相同的 \label 兩次

這個問題是已經回答的問題的延伸定義相同的 \label 兩次。我正在嘗試找到解決方案來解決中描述的問題定義相同的 \label 兩次,同時也允許呼叫主文檔的文檔之間進行交叉引用。例如,請參閱以下三個嵌套檔案及其輸出:

第一個文件

\documentclass{article}
\usepackage{catchfilebetweentags}

\begin{document}

\section{FIRST FILE}

\subsection{FIRST FILE}\label{arrow}

\subsubsection{FIRST FILE \ref{hey}}

\ExecuteMetaData[example2]{tag}

Call the nested files again.

\ExecuteMetaData[example2]{tag}

\end{document}

第二個文件

\documentclass{article}
\usepackage{catchfilebetweentags}

\begin{document}

%<*tag>
\section{SECOND FILE}

\subsection{SECOND FILE}

\subsubsection{SECOND FILE \ref{hey}}

\ExecuteMetaData[example3]{tag}
%</tag>

\end{document}

第三個文件

\documentclass{article}
\usepackage{catchfilebetweentags}

\begin{document}

%<*tag>
\section{THIRD FILE}

\subsection{THIRD FILE \ref{arrow}}

\subsubsection{THIRD FILE}\label{hey}
%</tag>

\end{document}

給出以下結果:

在此輸入影像描述

我正在尋找的是保持文件 1、2 和 3 之間交叉引用的能力,這種能力工作得很好,直到我第二次調用文件 2,導致 1.1.1 和 2.1.1 中的引用為 5.1。 1 而不是3.1.1。正如之前提到的解決方案定義相同的 \label 兩次解決了問題,但當文件\refa\label在其他文件中時則無法解決。

相關內容