Text Formattingautomatic numbering in align* environment

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
zzziop
Posts: 7
Joined: Wed Mar 18, 2009 3:19 pm

automatic numbering in align* environment

Post by zzziop »

Hello,

I am using an align* environment because for nearly all of my lines, i do not want them to be numbered. But for a few certain ones, I do want them numbered. My question is how to get this done automatically.

I do know of two ways to do this, but they are not automatic and somewhat laborious. One is to use the align environment, and put a \notag command on every line where you don't want it numbered. The second way is to use align* and add a \tag{...} on the lines you do want numbered, but then these numbers are not automatically updated.

Any ideas?


Thanks in advance,

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

automatic numbering in align* environment

Post by Juanjo »

There is a simple, automatic way to do so, provided that you cite all the numbered equations. This is a reasonable requirement (if you never refer to a numbered equation, why do you number it?). In such a case, load the mathtools package (which replaces amsmath), write \mathtoolsset{showonlyrefs} in the preamble, use always align, add a \label command to the few equations you want to number and, of course, cite them anywhere with, say, \eqref. Look at the following example (compile it several times):

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage{mathtools}
\mathtoolsset{showonlyrefs}
\begin{document}
Text here
\begin{align}
a&=b, \\
c&=d, \label{eq:1} \\
e&=f.
\end{align}
By \eqref{eq:1}\ldots
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
zzziop
Posts: 7
Joined: Wed Mar 18, 2009 3:19 pm

Re: automatic numbering in align* environment

Post by zzziop »

Great, works perfectly!
Post Reply