TeX - LaTeX Asked by JPi on February 2, 2021
Since autonum
doesn’t play nicely with cleveref
(nor does the mathtools
automatic numbering option work for me), I’m looking for a simpler solution. I’d like equations to be numbered automatically if they have a label in them and not otherwise. How do I accomplish this?
See enter link description here to see what the problem is with autonum
and cleveref
.
documentclass{amsart}
usepackage{cleveref}
begin{document}
begin{multline} label{eq:one} % must have a number
z=a+b+c+d+e+f+g
+ h+i+j+k+ell+m+n+o+p+q+r+s+t+u+v+w+x+y.
end{multline}
begin{multline} % must not have a number
z=a+b+c+d+e+f+g
+ h+i+j+k+ell+m+n+o+p+q+r+s+t+u+v+w+x+y.
end{multline}
begin{gather} label{eq:two} % must have a number
x=y
end{gather}
begin{gather} % must not have a number
x=y
end{gather}
end{document}
You have misunderstood the purpose of autonum
. What determines whether an equation is numbered is not whether it has a label{}
, but whether it is referenced at any point, in other words - whether the document contains a ref{}
referring to that equation or not.
The cref{}
command is also supported, if cleveref
is loaded.
For example:
documentclass{article}
usepackage{amsmath,cleveref,autonum}
begin{document}
begin{multline}label{eq:a}
z=a+b+c+d+e+f+g
+ h+i+j+k+ell+m+n+o+p+q+r+s+t+u+v+w+x+y.
end{multline}
begin{multline}label{eq:b}
z=a+b+c+d+e+f+g
+ h+i+j+k+ell+m+n+o+p+q+r+s+t+u+v+w+x+y.
end{multline}
begin{gather}label{eq:c}
x=y
end{gather}
begin{gather}label{eq:d}
x=y
end{gather}
We reference the first verb|multline| environment, but not the second,
and the second verb|gather| environment, but not the first.
Hence. only cref{eq:a} and cref{eq:d} will be numbered,
even though all equations are labelled.
end{document}
If you don't want an equation numbered and know you'll never refer to it, you may just as soon use the starred form of the environment. The autonum
package is intended specifically to avoid the need to alter the equation itself based on whether it is ever referred to. If it depended on the addition or deletion of a label{}
, the package would lose its point since adding or deleting a star is at least as easy and, arguably, easier.
Answered by cfr on February 2, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP