6

How use "align" but with numeration of just some equation ? For example,

\begin{align}

f(x)&=P(x)\\

&= Q(x)\\

&=R(x)

\end{align}

will numerate all equation. How can I do if I want to numerate only the second equation for example ? I tried

\begin{align*}

f(x)&=P(x)\\

&= Q(x)\tag{2}\\

&=R(x)

\end{align*}

but I would like to numerote it in a coherent way with previous numerotation, i.e. if the previous equation is numeroted with (6) I want to give automatically the number (7). Is it possible ?

Surb
  • 319

3 Answers3

6

When using align or similar environments, \nonumber suppresses numbering of the given line. You only need \tag if you need special labelling.

Sample output

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{align}
  f(x)&=P(x) \nonumber \\
      &=Q(x) \label{eq:2} \\
      &=R(x) \nonumber \\
      &=S(x) \tag{S}\label{eq:S} \\
      &=T(x) \nonumber
\end{align}

Refer to \eqref{eq:2} and \eqref{eq:S}

\end{document}
Andrew Swann
  • 95,762
3

This does what you want:

\begin{equation}
\begin{aligned}
f(x)&=P(x)\\
&= Q(x)\\
&=R(x)
\end{aligned}
\end{equation}

The equation number is vertically centred by default. You can have it at the top or at the bottom with the options [t] or [b].

Bernard
  • 271,350
  • I think the OP wants this without the \tag{2} so gets the automatic number – David Carlisle Dec 27 '17 at 10:55
  • Yes, @DavidCarlisle is right. I don't want to have \tag{2} to have a coherent number with previous numerotations. – Surb Dec 27 '17 at 11:01
  • I tried it work (except replace \tag by \label – Surb Dec 27 '17 at 11:02
  • @Surb: Yes, I copied your code to start with, and forgot to remove \tag{2}. I've fixed it. – Bernard Dec 27 '17 at 11:04
  • But we agree that I must add \label{xx} at the second line, no ? (since you erased it). Because by writting \label{xx} at the second line, I indeed have a correct number, and by putting exactly the code you wrote, noting appear. – Surb Dec 27 '17 at 11:12
  • @Surb not the number is for the entire equation, so you can put \label anywhere, eg just after \begin{equation} – David Carlisle Dec 27 '17 at 11:15
  • @DavidCarlisle: I see. But what I would like is to give a number only on specific equation, not all of them (for example just the second or the third). Is there such a possibility ? – Surb Dec 27 '17 at 11:49
  • @Surb this is for a single number (from equation) if you really want to number the individual lines go back to using align as in your original and use \nonumber on rows not to be numbered, as it was mentioned previously in comments. However not numbering f(x)=P(x) but numbering =Q(x) would look pretty strange. – David Carlisle Dec 27 '17 at 11:54
  • 1
    @Surb: You also have the possibility to nest all this in the subequations environment which will number lines as (7a), (7b), &c., with always the possibility to use \nonumber (or \notag) for specific lines. – Bernard Dec 27 '17 at 12:08
2

I would choose the path of Andrew swann, but instead of removing numbers in align I would add numbers to align* this has already been shown, and here I cite the answer from align* but show one equation number at the end :

Use \tag:

\documentclass{article}
\usepackage{amsmath}
\newcommand\numberthis{\addtocounter{equation}{1}\tag{\theequation}}
\begin{document}
\begin{align*}
    a &=b \\
    &=c \numberthis \label{eqn}
\end{align*}
Equation \eqref{eqn} shows that $a=c$.
\begin{equation}
    d = e
\end{equation}
\end{document}

See page 3 of the amsmath package >documentation for details.

This answer was given by Ian Thompson

dexteritas
  • 9,161