1

I have a finished document with labeled equations and their respective references. If I update this document by adding a new equation in the middle of the text, would there be a way of both labels and references of the subsequent equations to be automatically updated?

7
  • 4
    Welcome to TeX.SE! Of course. You only need to car for unique equation labels and in references use correct labels.
    – Zarko
    Sep 1, 2020 at 17:32
  • 1
    Please tell us how you've labelled equations. E.g., have you used \label instructions? And, which command(s) have you employed to create cross-references to the labeled equations? Please be specific.
    – Mico
    Sep 1, 2020 at 17:46
  • 2
    equations in latex are automatically numbered by default so the numbering should just work automatically. there is no need to change the \label that is the whole reason for using \label and \ref that you can add and remove equations and have the numbers be re-calculated. Sep 1, 2020 at 18:51
  • Hi Mico, indeed I was misusing the \label option; I was not using the colon between eq and number; for example \label{eq1}. Thanks a lot for you, Zarko and David. Sep 2, 2020 at 2:04
  • there is nothing special about colon, but it is best not to use numbers in the label as it confuses you if the equation with numer 3 has \label{2} Sep 2, 2020 at 7:12

1 Answer 1

4

The reason that LaTeX has \label and \ref is for the case that you describe. There is no need to change the label keys, the numbering and cross referencing will automatically adjust as equations are added or removed.

\documentclass{article}

\begin{document}

See Equation (\ref{eq:xy}).

An equation
\begin{equation}
  \label{eq:defx}
  x=2
\end{equation}

Some text.

Another equation
\begin{equation}
  \label{eq:xy}
  x=y
\end{equation}

\end{document}

The first sentence typesets as "See Equation (2)"

enter image description here

Now if the document is edited, inserting a new equation

\documentclass{article}

\begin{document}

See Equation (\ref{eq:xy}).

An equation
\begin{equation}
  \label{eq:defx}
  x=2
\end{equation}

Insert this equation
\begin{equation}
  \label{eq:oops}
  1=0
\end{equation}

Some text.

Another equation
\begin{equation}
  \label{eq:xy}
  x=y
\end{equation}

\end{document}

Then after running LaTeX a couple of times the first line will automatically adjust to "See Equation (3)"

enter image description here

1
  • Thank you very much David! Sep 2, 2020 at 1:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .