3

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. – Siddhartha 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}? – Siddhartha May 19 '17 at 23:00
4

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]
\begin{equation}\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}
\end{equation}
\lipsum[3]

\end{document}

enter image description here

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.

| improve this answer | |
3

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 ...
\begin{equation}\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}
\end{equation}
Some other text below the formula ...

\end{document}

enter image description here

| improve this answer | |
2

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} 
| improve this answer | |
1

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

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

zz
\begin{equation}
  1=2
\end{equation}
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}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.