xr-hyper 与 amsart 兼容吗?

xr-hyper 与 amsart 兼容吗?

xr-hyper我在使用(文件之间的交叉引用)类时遇到了问题amsart

以下代码在尝试编译两个.tex文件时出现错误(见下文);无论我先编译哪个文件,都会通过,但第二个文件编译失败。如果我用 替换,它会按预期\usepackage{amsart}工作\usepackage{article}

\usepackage{xr}如果我写的不是,文件确实可以编译(并显示正确的引用)\usepackage{xr-hyper},但在这种情况下,跨文件超链接似乎被误导了(对于article类和amsart类而言)。

有什么建议么?


文件一,称为my_part_I.tex


\documentclass{amsart}

\usepackage{xr-hyper}
\usepackage{hyperref}

\externaldocument{my_part_II}

\begin{document}

\section{Introduction for Part I}
\label{sec:part_I}

See \ref{sec:part_I} or \ref{sec:part_II}.

\end{document}


文件二,称为my_part_II.tex


\documentclass{amsart}

\usepackage{xr-hyper}
\usepackage{hyperref}

\externaldocument{my_part_I}

\begin{document}

\addtocounter{section}{1}
\section{Introduction for Part II}
\label{sec:part_II}

See \ref{sec:part_I} or \ref{sec:part_II}.

\end{document}


编辑:根据要求,这里有一些有关错误的更多信息。

我必须承认我不是 LaTeX 专家,所以我不确定我是否看到了正确的错误。

--

我的 TeXworks 控制台给我

! Missing number, treated as zero.
<to be read again> 
                   {
l.11 \section{Introduction for Part II}

当我尝试编译时my_part_II.tex

--

当我在 Overleaf 上尝试同样的事情时(这需要一些解决方法xr-hyper,但我经常在article类中使用),文件编译但有几个警告(并且跨文件引用在中显示为“??” my_part_II.pdf)。编译后my_part_I.tex,我得到

Label `tocindent-1' multiply defined.
Label `tocindent0' multiply defined.
Label `tocindent1' multiply defined.
Label `tocindent2' multiply defined.
Label `tocindent3' multiply defined.

如果我编译my_part_II.tex,我会得到

Reference `sec:part_I' on page 1 undefined on input line 50.

答案1

如果你编译其中一个文件(不带 xr-hyper)并查看 aux 文件,你会看到如下标签定义:

\newlabel{tocindent-1}{0pt}
\newlabel{tocindent0}{0pt}
\newlabel{tocindent1}{17.77782pt}
\newlabel{tocindent2}{0pt}
\newlabel{tocindent3}{0pt}

amsart 使用它来存储下次运行的缩进值。

这些\newlabel定义命令\r@tocindent0等。当您加载外部文档时,amsart 要么只看到来自外部文档的 \newlabel(由于 xr-hyper 添加了文件信息,因此它具有错误的值和错误的格式)和错误,要么看到来自辅助文件的 \newlabel 并抱怨标签增多。

我认为解决这个问题的唯一方法是使用前缀来确保名称不重叠:\externaldocument[A-]{my_part_II}

附注:虽然目前 xr 不会出错,但结果还是错误的。此外,对于下一个 LaTeX,xr 和 xr-hyper 将合并并执行相同的操作。

相关内容