The purpose of the \label
–\ref
mechanism is to free the user from the burden of renaming cross references as soon as some of the numbers change.
Your projected scheme is completely equivalent to not adding any \label
command and doing cross references just by the assigned number. Yes, you have the benefit of the \ref
command, but your code would be completely equivalent with
\DeclareRobustCommand{\eqref}[1]{\eqrefaux#1\eqrefaux}
\def\eqrefaux eq#1\eqrefaux{\textup{(#1)}}
in the preamble and typing
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
x &= 2^{100}, \\
y &= 2^{100}, \\
z &= 2^{100}.
\end{align}
These are \eqref{eq4.1} and \eqref{eq4.2} and \eqref{eq4.3}.
\end{document}
The macros just remove the eq
string. Note that this wouldn't need two passes, because it doesn't exploit \label
. But it's wrong, deadly wrong.
If you add an equation somewhere, you need to keep track of where it was and to find all cross references with a higher number, start from the one with the largest number, adding one to it and go down step by step. A nightmare! And a sure source of errors: suppose your chapters are stored in different files: you need to check each one of them and fix the cross references.
And, maybe, your supervisor will email you, a week later, “Dear CroCo, that equation you added last week should be removed”. Did you think to this? By Murphy's law, this will happen with utmost certainty.
There is already a flexible mechanism: using \label
and \ref
properly!
Add meaningful names to your equations,
\documentclass{article}
\usepackage{amsmath}
\usepackage{showkeys} % remove for final versions
\begin{document}
\begin{align}
x &= 2^{100}, \label{eq-x100}\\
y &= 2^{100}, \label{eq-y100}\\
z &= 2^{100}. \label{eq-z100}
\end{align}
These are \eqref{eq-x100} and \eqref{eq-y100} and \eqref{eq-z100}.
\end{document}
You won't have to worry about adding or removing equations or other numbered objects, because LaTeX will take care of this. Even warning you if you have cross-referenced an equation (or chapter, section, whatever) you have meanwhile removed.
With showkeys
you have the labels shown in the PDF, so you can easily skim through it to find the exact name when you want to do \ref
. If the names are good enough, you'll probably remember them.
![enter image description here](https://cdn.statically.io/img/i.sstatic.net/RMw0e.png)
\label{def:x}
(meaning definition of x), etc.\label{eq:4-def-x}
to borrow an idea from another comment?\label
is to assign a name completely independent from the number which will be eventually assigned to the equation. So you need to change neither the label nor the reference at any time, for as many equations you add (or remove).