直接在公式编号中添加引用/交叉引用

直接在公式编号中添加引用/交叉引用

我正在编写一份引用多本教科书中的方程式的文档。为了让读者能够快速跳转到精确的在每个源中的位置,我想添加对方程编号的引用,如下所示:

A=B+C(1,参见[1](1.123))

其中,公式 1(A = B + C)改编自来源 [1] 中的公式 (1.123)。

答案1

您可以使用 ' 命令定义新的标签形式mathtools。在这里,我定义了一个命令\tagcite,您可以在需要添加引用的方程式之前调用它。它需要两个参数:引用标签和方程式编号。

\documentclass{article}
\usepackage{mathtools}
\newtagform{tagcite}{(}{)}
\newcommand*{\tagcite}[2]{%
    \renewtagform{tagcite}{(}{, cf.\@ \cite{#1} (#2))}
    \usetagform{tagcite}
}
\AfterEndEnvironment{equation}{\usetagform{default}}
\begin{document}
\tagcite{ref}{1.123}
\begin{equation}
\label{equation}
A + B = C
\end{equation}
Reference to equation \eqref{equation}.
\tagcite{otherref}{2.345}
\begin{equation}
D + E = F
\end{equation}
\begin{thebibliography}{1}
    \bibitem{ref} Source
    \bibitem{otherref} Other source
\end{thebibliography}
\end{document}

请注意,我添加了行

\AfterEndEnvironment{equation}{\usetagform{default}}

在每个环境之后将标签格式重置为默认格式equation,这样您在使用后就无需手动重置它\tagcite,但这也会导致如果您在文档中使用其他标签格式,它们将不断被重置。如果您打算使用其他标签格式,您可能需要删除此行并在必要时手动重置标签格式。

相关内容