\begin{align}
\begin{split} \label{eq:28}
Pr(A) ={}& (0.457 \times 1) + (0.04 \times 1) \\ ={}& 0.497
\end{split} \\
\begin{split}
Pr(A \ \& \ B) ={}& (0.457 \times 1) + (0.256 \times 1) \\
& + (0.157 \times 1) + (0.04 \times 1) = 0.91 \label{eq:29}
\end{split}
\end{align}
我想要的是 Pr(A) 和 Pr(A & B) 也相互对齐。有人能帮忙吗?
答案1
快速而肮脏:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align}
\begin{split} \label{eq:28}
\rlap{$\Pr(A)$}\hphantom{\Pr(A\,\&\, B)} ={}
& (0.457 \times 1) + (0.04 \times 1) \\
={}& 0.497
\end{split} \\
\begin{split}
\Pr(A\,\&\,B) ={}& (0.457 \times 1) + (0.256 \times 1) \\
& + (0.157 \times 1) + (0.04 \times 1) = 0.91 \label{eq:29}
\end{split}
\end{align}
\end{document}
答案2
另外两种可能的布局,包括alignat
:
\documentclass{article}
\usepackage{mathtools}
\usepackage{stackengine}
\begin{document}
\setcounter{equation}{27}
\begin{alignat}{2}
& \Pr(A) & & = (0.457 × 1) + (0.04 × 1) = 0.497 \\[1ex]
& \Pr(A\,\&\,B) & & =\begin{multlined}[t] (0.457 × 1) + (0.256 × 1) \\
+ (0.157 × 1) + (0.04 × 1) = 0.91
\end{multlined} \label{eq:29}\refstepcounter{equation} \tag*{\bllap[1.5ex]{(\theequation)}}
\end{alignat}
\begin{alignat}{3}
& \Pr(A) & & = (0.457 × 1) + (0.04 × 1) & & = 0.497 \\[1ex]
& \Pr(A\,\&\,B) & & = (0.457 × 1) + \mathrlap{(0.256 × 1)} \notag \\
& & & + (0.157 × 1) + (0.04 × 1) & & = 0.91
\label{eq:29-a}
\end{alignat}
\end{document}