I got a document with many (over 100) equations, in which I think during the work on it I'll have to change, switch, remove them etc. I often want to refer to an equation but due to the work in progress it's not really convenient to \label every equation e.g. with a number and \ref to it. Is there an easier way to do this with some auto labeling and a straight forward refer even if I change order etc.
- 506,678
1 Answers
If you're \labeling the equations numerically in ascending order, you're not using the tool appropriately. The arguments of \label should indicate, in some abbreviated and hopefully recognizable way, what it being cross-referenced. E.g., one might write
\begin{equation} \label{eq:einstein_energy}
E=mc^2
\end{equation}
With this setup, no matter if the equation is ends up being numbered 1, 55, or any other number, you can cross-reference from anywhere in the document by writing
\ref{eq:einstein_energy}
You certainly won't have to change the argument of \label (and \ref) simply because the number assigned to the equation has changed.
If you need to cross-reference ranges of equations, you should look into loading the cleveref package and using its \crefrange macro, as is demonstrated in the following example. Note that the middle three equations aren't even assigned \labels.
For more information on cross-referencing mechanisms and packages, please the posting Cross-reference packages: which to use, which conflict?
\documentclass{article}
\usepackage[noabbrev]{cleveref} % for "\crefrange" macro
\setlength\textwidth{3in} % just for this example
\begin{document}
\begin{equation}\label{eq:one_one} 1+1=2 \end{equation}
\begin{equation} 2+2=4 \end{equation}
\begin{equation} 3+3=6 \end{equation}
\begin{equation} 4+4=8 \end{equation}
\begin{equation}\label{eq:zero_zero}0+0=0 \end{equation}
A cross-reference to \crefrange{eq:one_one}{eq:zero_zero}.
\end{document}
- 506,678

\label\refmechanism is for. – Steven B. Segletes Oct 13 '17 at 10:09\begin{equation}E=mc^2\label{eq:1}\end{equation}, but rather one should say something like\begin{equation}E=mc^2\label{eq:einstein}\end{equation}. And you don't have to\labelall the equations...only the ones you reference. Bottom line is that automatic labeling is meaningless labeling. – Steven B. Segletes Oct 13 '17 at 10:21