2

I want to align these equations. I don't think they are prefectly aligned. My code :

\begin{align}
    \mathbb{E}_{2}[S_{3}](HH) = p S_{3}(HHH) + (1-p) S_{3}(HHT) \label{eqn1}\\
    \mathbb{E}_{2}[S_{3}](HT) = p S_{3}(HTH) + (1-p) S_{3}(HTT) \label{eqn2}\\
    \mathbb{E}_{2}[S_{3}](TH) = p S_{3}(THH) + (1-p) S_{3}(THT) \label{eqn3}\\
    \mathbb{E}_{2}[S_{3}](TT) = p S_{3}(TTH) + (1-p) S_{3}(TTT) \label{eqn4}.
\end{align}

Output

1
  • 1
    Welcome to TeX.SE. You just need to specify the alignment points. That is, use &= instead of =. This will align the equal signs. If you also want to have the + signs aligned then use the \begin{alignat}{3} and \end{alignat} instead and replace the = with &=, and replace the + with &&+. Dec 20, 2020 at 6:00

1 Answer 1

3

Here are 3 options:

  1. Regular align with the alignment around =.

  2. A right-left alignment around = as well as a left-alignment around +.

  3. An alignment around = and +, with the terms centre-aligned (using \eqmakebox[<tag>] from eqparbox).

enter image description here

\documentclass{article}

\usepackage{amsmath,amssymb,eqparbox}

\begin{document}

\begin{align}
  \mathbb{E}_2[S_3](HH) &= p S_3(HHH) + (1 - p) S_3(HHT) \\
  \mathbb{E}_2[S_3](HT) &= p S_3(HTH) + (1 - p) S_3(HTT) \\
  \mathbb{E}_2[S_3](TH) &= p S_3(THH) + (1 - p) S_3(THT) \\
  \mathbb{E}_2[S_3](TT) &= p S_3(TTH) + (1 - p) S_3(TTT)
\end{align}

\begin{alignat}{2}
  \mathbb{E}_2[S_3](HH) &= p S_3(HHH) &&+ (1 - p) S_3(HHT) \\
  \mathbb{E}_2[S_3](HT) &= p S_3(HTH) &&+ (1 - p) S_3(HTT) \\
  \mathbb{E}_2[S_3](TH) &= p S_3(THH) &&+ (1 - p) S_3(THT) \\
  \mathbb{E}_2[S_3](TT) &= p S_3(TTH) &&+ (1 - p) S_3(TTT)
\end{alignat}

\begin{align}
  \eqmakebox[LHS]{$\mathbb{E}_2[S_3](HH)$} &= \eqmakebox[pS]{$p S_3(HHH)$} + \eqmakebox[1-pS]{$(1 - p) S_3(HHT)$} \\
  \eqmakebox[LHS]{$\mathbb{E}_2[S_3](HT)$} &= \eqmakebox[pS]{$p S_3(HTH)$} + \eqmakebox[1-pS]{$(1 - p) S_3(HTT)$} \\
  \eqmakebox[LHS]{$\mathbb{E}_2[S_3](TH)$} &= \eqmakebox[pS]{$p S_3(THH)$} + \eqmakebox[1-pS]{$(1 - p) S_3(THT)$} \\
  \eqmakebox[LHS]{$\mathbb{E}_2[S_3](TT)$} &= \eqmakebox[pS]{$p S_3(TTH)$} + \eqmakebox[1-pS]{$(1 - p) S_3(TTT)$}
\end{align}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .