重印方程式

重印方程式

假设我有一个如下方程:

\begin{align} \label{eq:ajk}
a_{jk} = a_{j} - a_{k} %suppose this is a very very long equation with many lines
\end{align}

我怎样才能稍后在文档中再次打印完全相同的方程式而实际上无需再次编写该方程式?

我正在寻找类似的东西:\ref{eq:ajk}具有所需输出,即方程式以相同的方程式编号重新打印,而不仅仅是方程式的超链接。我正在使用amsmath包,如果我需要使用任何其他包,那也没问题。

这可能吗?

答案1

添加到这个帖子获得显示样式的重复---

\documentclass{article}
\usepackage{amsmath}

\makeatletter
%%  The basic form (https://tex.stackexchange.com/a/75920/146828)
\newcommand{\repeatable}[2]{%
  \label{#1}\global\@namedef{repeatable@#1}{#2}#2
                           }
%%  In-line style (https://tex.stackexchange.com/a/75920/146828)
\newcommand{\eqrepeat}[1]{%
  \@ifundefined{repeatable@#1}
                 {$nothing$                         (?)}
                 {$\@nameuse{repeatable@#1}$ \eqref{#1}}}
%%  Display-style (slight modification of the above)
\newcommand{\eqrepalign}[1]{%
  \@ifundefined{repeatable@#1}{
              \begin{align} 
                 No\; such\; equation   \tag{?}
              \end{align} 
                              }{%
              \begin{align} 
               \@nameuse{repeatable@#1}  \tag{\ref{#1}}
              \end{align} 
                               }%
                           }
\makeatother


\begin{document}

\noindent
Suppose we have an equation we'd like to repeat---
%
\begin{align}  \repeatable{eq:good}{
   a_{jk} = a_{j} - a_{k}                          }
\end{align}
%
and some other equation, we'd never repeat---
%
\begin{align}
   f(x) = x^2 + 2x + 1
\end{align}
%
We can re-quote the first as: \eqrepeat{eq:good},\\ 
or in display-style as follows---
%
    \eqrepalign{eq:good}
%
but in case of an error it gives: \eqrepeat{eq:bad},\\ 
and displaying a dummy message---
%
    \eqrepalign{eq:bad}
%
%
%
However, the next equation is naturally numbered\ldots
%
\begin{align}
   a^n + b^n = c^n
\end{align}
%

\end{document}

得到如下输出——

相关内容