我有以下代码:
$\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}$
我想将最后一行标记为 (2)。我该怎么做?
答案1
您需要的是split
。系统将自动分配号码。
\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}
注意我如何为差分符号设置正确的间距。如果您改变主意并希望数字垂直居中,请删除该tbtags
选项。
答案2
使用[b]
选项aligned
而不是[t]
。另外,正如其他人提到的,$
s 用于内联数学。
\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}
答案3
这很简单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}
答案4
$
用于内联数学,但通常你只显示数学结构的数字
\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}