# Numbering one equation in aligned environment

I have the following code:

\begin{aligned}[t] P\{X\in A\}&=\int_A\int_{-1}^1 f(x, y)dydx \\ &=\int_A\int_{-1}^1\frac{1}{4}dydx \\ &=\int_A\frac{1}{4}\times 2dx \\ &=\int_A\frac{1}{2}dx \end{aligned}


I want to label the last line as (2). How do I do this?

• Where should the tag go? THe will be text after the environment, I suppose. – Bernard May 19 '17 at 22:53
• I want the number (2) to show after the last equation. I tried \hfill(2) but it doesn't work. – Thomas May 19 '17 at 22:55
• why \begin{aligned} rather than \begin{align} ? inline math doesn't normally get equation numbers – David Carlisle May 19 '17 at 22:58 • @DavidCarlisle Ok, how would I do it if I were to use \begin{align}? – Thomas May 19 '17 at 23:00 ## 4 Answers What you need is split. The number will be assigned automatically. \documentclass{article} \usepackage[tbtags]{amsmath} \usepackage{lipsum} % just for the example \newcommand{\diff}{\mathop{}\!d} % for integrals \begin{document} \lipsum*[2] $$\label{eq:someprob} \begin{split} P\{X\in A\} &=\int_A\int_{-1}^1 f(x, y)\diff y \diff x \\ &=\int_A\int_{-1}^1\frac{1}{4}\diff y \diff x \\ &=\int_A\frac{1}{4}\cdot 2\diff x \\ &=\int_A\frac{1}{2}\diff x \end{split}$$ \lipsum[3] \end{document}  Note how I got the right spacing for the differential symbols. If you change your mind and prefer a vertically centered number, remove the tbtags option. That's pretty simple with align: \documentclass{article} \usepackage{amsmath} \begin{document} Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. \begin{align} P\{X\in A\}&=\int_A\int_{-1}^1 f(x, y)dydx \notag\\ &=\int_A\int_{-1}^1\frac{1}{4}dydx \notag \\ &=\int_A\frac{1}{4}\times 2dx \notag\\ &=\int_A\frac{1}{2}dx \tag{2} \end{align} Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. Blah blah blah. \end{document}  Use the [b] option for aligned rather than the [t]. Also, as others mentioned s are used for inline math.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

Some text above the formula ...
\label{eq:niceformula} \begin{aligned}[b] P\{X\in A\} &=\int_A\int_{-1}^1 f(x, y)dy\, dx \\ &=\int_A\int_{-1}^1\frac{1}{4} dy\, dx \\ &=\int_A\frac{1}{4}\cdot 2 dx \\ &=\int_A\frac{1}{2} dx \end{aligned}
Some other text below the formula ...

\end{document}


\$ is for inline math but normally you only number display math constructs

\documentclass{article}

\usepackage{amsmath}

\begin{document}

zz
$$1=2$$
zz
\begin{align}
P\{X\in A\}&=\int_A\int_{-1}^1 f(x, y)dydx \notag\\
&=\int_A\int_{-1}^1\frac{1}{4}dydx \notag\\
&=\int_A\frac{1}{4}\times 2dx \notag\\
&=\int_A\frac{1}{2}dx
\end{align}
\end{document}