有没有办法引用你的编号方程式?

有没有办法引用你的编号方程式?

以下是摘录文件

\begin{align}
f(x) &= g(x) + h(x)//
&= 3x + 8x^2 + 1//
&= 3 + 8 + 1//
\end{align}

所以当我编译它时(假设这是我唯一拥有的东西),LaTeX 会将行编号为 1,2,3。

我希望能够引用这些行,因为将来我可能会添加更多 \equations 或更多 \aligns,并且可能将它们放在前面或后面。有没有办法引用这些行,而无需手动输入 $(1)$、$(2)$?

答案1

编译两次或更多次。

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
E &\not= mc^2 \label{Einstein}\\
PV &= nRT \label{Gas}
\end{align}
\newpage
Please see equation~\ref{Einstein} on page~\pageref{Einstein}.
\end{document}

在此处输入图片描述

在此处输入图片描述

答案2

在您的 align 环境中,有多种方法可以引用这三行。首先,您必须为每行提供一个标签,然后您可以使用 \ref、\eqref、\fref 引用它们。为了说明这一点,我发布了一整篇 mwe。

\documentclass{scrartcl}
\usepackage[english]{babel} 
\usepackage{amsmath}
\usepackage[english]{fancyref}
\newcommand{\bs}{\ensuremath{\backslash}}
\begin{document}
\begin{align}
\label{eq:first}
f(x) &= g(x) + h(x)\\
\label{eq:second}
&= 3x + 8x^2 + 1\\
\label{eq:third}
&= 3 + 8 + 1
\end{align}

My first equation with label~\ref{eq:first}. My second equation with label~\ref{eq:second}. And my third equation with label~\ref{eq:third}.
\vskip 1em
You can also try \bs eqref. Then you'll get: My first equation with label~\eqref{eq:first}. My second equation with label~\eqref{eq:second}. And my third equation with label~\eqref{eq:third}.
\vskip 1em
Or, you can try \bs fref using the fancyref package which automatically refers to the correct page and gives you the name of the reference object, i.e. 'equation' in this case: My first equation with label~\fref{eq:first}. My second equation with label~\fref{eq:second}. And my third equation with label~\fref{eq:third}. That way you can easily refer to equations, sections, figures, tables on other pages. Try something like this: \fref{eq:nextpage} or \fref{eq:faraway}.
\newpage
\begin{equation}
\label{eq:nextpage}
a^2+b^2=c^2
\end{equation}
\newpage
\newpage
\newpage
\newpage
\begin{equation}
\label{eq:faraway}
f(x)=x^2
\end{equation}
\end{document}

相关内容