8

Suppose I have an equation like :

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

How can I print the exact same equation again later in my document without actually writing the equation again?

I am looking for something like : \ref{eq:ajk} with the desired output that the equation get's reprinted with the SAME equation number and not just an hyperlink to the equation. I am using amsmath package and it's fine if I need to use any other package.

Is this possible?

Nitin
  • 295
  • 1
  • 11

1 Answers1

9

To add to this post to get display-style repetitions---

\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}

to get an output that looks like--

Partha D.
  • 2,250