0

I have used the following codes to produce two equations like in the image 28 and 29

\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}

What I want is, Pr(A) and Pr(A & B) to also align with each other. Can anyone please help?

  • but they are (right) aligned at sign =. how you like to have aligned. now equation are looking well ... welcome to tex.se! – Zarko Aug 9 '17 at 21:52
0

Quick and dirty:

\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}

Result

1

Two other possible layouts, with 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} 

enter image description here

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.