# Make align* number the last equation

I am using the align* environment to write equations expanding several lines. I would like to define a command sequence in the preamble, such that the last equation of this block will always be numbered (while the others remain unnumbered). For example, the block

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
x & =2+2\\
& =3+1\\
& =4
\end{align*}
\end{document}


will visually look like:

x = 2+2
= 3+1
= 4     (1)

• Welcome to TeX.sx! It's always the best adding minimal working example (MWE) that illustrates your problem. I hope next time you will provide one. Aug 11 '12 at 11:28
• @MarcoDaniel: Is a MWE really appropriate in this case? They don't have a problem, but something they wish to achieve. It's pretty clear to me from just what the OP has written, what they're looking for. Aug 11 '12 at 12:21
• @NieldeBeaudrap: I think so. It's easier to copy paste a mwe. Aug 11 '12 at 12:23
• @MarcoDaniel: I suppose that, because amsmath is my bread and butter, it's almost as easy for me to open a new article in my editor of choice, paste that equation, and then manually write the missing \usepackage{amsmath} which I know goes there anyway. For anything moderately complicated, or using many/obscure packages, I'd agree; but I grasp simple problems like this one more quickly when it's a code snippet whose context is obvious, than a compilable document (as in my recent revision) in which 60% of the content is something which I would have known goes there anyhow. Aug 11 '12 at 12:36

It's easier suppressing the first lines. Every line ends up with \\ except the last one. So simple redefine \\ inside the environment align.

\documentclass{report}
\usepackage{amsmath}
\makeatletter
\def\Let@{\def\\{\notag\math@cr}}
\makeatother
\begin{document}
\begin{align}
x & =2+2\\
& =3+1\\
& =4
\end{align}
\end{document}


• Hi. This solution works best for me. Thanks!
– Sam
Aug 11 '12 at 19:42
• +1 but for every align? what happens if they want to turn the behaviour off? Aug 11 '12 at 21:00
• @cmhughe: You can add a simple switch like \def\changenumberingon{\def\Let@{\def\\{\notag\math@cr}} and \def\changenumberingoff{\def\Let@{\def\\{\notag\math@cr}} Aug 11 '12 at 21:05

What you want is aligned with bottom vertical alignment:

\documentclass{report}
\usepackage{amsmath}
\begin{document}
\begin{aligned}[b] x & =2+2\\ & =3+1\\ & =4 \end{aligned}
\end{document}


• This is something which I wish I had known quite some time ago! Aug 11 '12 at 12:22
• @NieldeBeaudrap: Me too Aug 11 '12 at 12:26
• This is perhaps the simplest. Thanks! I actually work with LyX so I prefer to redefine the align* environment. But in LaTeX it seems to me like the best option.
– Sam
Aug 11 '12 at 19:44

I'm a little surprised no one has gone for the 'simple' solution involving \notag

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
x & =2+2\notag\\
& =3+1\notag\\
& =4
\end{align}
\end{document}

• In fact the approved solution by @Marco Daniel uses notag. I started your way, but I grew tired and did something similar, defined \n as \notag\\ so I can use \n or \\ depending if I want numbering or not. Aug 11 '12 at 21:34

You may define an environment based on align* which does what you want. I'll call it Salign.

\documentclass[11pt]{article}
\usepackage{amsmath}

\newcommand*{\starnr}{\stepcounter{equation}\tag{\theequation}}
\makeatletter
\newenvironment{Salign}
{\start@align\@ne\st@rredtrue\m@ne}
{\starnr\endalign}
\makeatother

\begin{document}
\begin{Salign}
x&=2+2\\
&=3+1\\
&=4
\end{Salign}

\end{document}


• +1 for the idea with \stepcounter. I really miss something like \dotag which would perform this automatically.
– yo'
Aug 12 '12 at 20:34

use a tag after the last equation

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
x & =2+2\\
& =3+1\\
& = 4  \tag{1}
\end{align*}
\end{document}


this solution work for me

• I happen to be changing my code indentation, thanks for your help. May 5 '17 at 14:17
• You could improve your answer by making the code into a complete compilable example, by adding the pre-amble and document environment. May 5 '17 at 14:36
• This solution is slightly less desirable as it does not take the automatic equation numbering into account. If say, you add in another (numbered) equation below this, it will turn up as (1), not (2) as it should. This requirement wasn't stipulated explicitly by OP, but just something to note, I guess.
– Troy
May 5 '17 at 14:42
• Yes, i understand the advantage of marking the tag in implicit way. My solution is a dirty way. In some situation, the tag is static and complicated, like (8.21), and I have to explicitly refer it many times in my article. For simplicity, i just want to write it down in explicit way. May 6 '17 at 3:02