5

I am trying to align three equations using align like this but I am not sure where to put the &.

p(k+1) = p(k) * P 
         p(k) = p(k-1) * P
                p(k-1) = p(k-2) * P 

Attempt:

\begin{align*}
p(k+1) = &p(k) \cdot P \\
p(k) = &p(k-1) \cdot P \\
&p(k-1) = p(k-2) \cdot P
\end{align*}
Clone
  • 533

4 Answers4

8

Here are two possible ways using aligned.

\documentclass{article}
\usepackage{mathtools}
\begin{document}
\begin{align*}
p(k+1) &= \begin{aligned}[t] p(k) &\cdot P \\
p(k) &= \begin{aligned}[t]p(k-1)& \cdot P \\
p(k-1) &= p(k-2) \cdot P
\end{aligned}
\end{aligned}
\end{align*}


\begin{equation*}
p(k+1) = \begin{aligned}[t] p(k) &\cdot P \\
p(k) &= \begin{aligned}[t]p(k-1)& \cdot P \\
p(k-1) &= p(k-2) \cdot P
\end{aligned}
\end{aligned}
\end{equation*}
\end{document}

enter image description here

5

I propose these solutions based on a single alignat. The second solution aims at centring \cdot w.r.t. the = sign (at the cost of a larger spacing around it):

    \documentclass{article}
    \usepackage{mathtools}
    \usepackage{calc}
    \newcommand{\mycdot}{\makebox[\widthof{${}={}$}]{$\cdot$}}

    \begin{document}

    \begin{alignat*}{2}
    p(k+1) = p(k) &\cdot P \\
                     p(k) &= & p(k-1) & \cdot P \\
     && p(k-1)&= p(k-2) \cdot P
    \end{alignat*}

    \begin{alignat*}{2}
    p(k+1) = p(k) &\mycdot \mathrlap{P} \\
                     p(k) &= & p(k-1) &\mycdot P \\
     && p(k-1)&= p(k-2) \cdot P
    \end{alignat*}

    \end{document} 

enter image description here

Bernard
  • 271,350
5

The \phantom is your friend when such case occurs. I propose the solution based on classical \eqalign and \phantom.

$$\def\={\mathrel{\phantom{=}}}\def\x{\=\phantom{p(k)}\=}
  \eqalign{
   p(k+1) & =  p(k) \cdot P \cr
          &\=  p(k) = p(k-1) \cdot P \cr
          &\x         p(k-1) = p(k-2) \cdot P 
}
$$

\bye
wipet
  • 74,238
5

I'd use array for this. The centered dot wants to be centered, the only phantom is needed to get the same width also in the last case.

\documentclass{article}
\usepackage{amsmath,array}

\begin{document}

\begin{equation*}
\renewcommand{\arraystretch}{1.2}
\setlength{\arraycolsep}{0pt}
\begin{array}{ r *{3}{ >{{}}c<{{}} l } }
p(k+1) = p(k) &\cdot& P \\
         p(k) &  =  & p(k-1) &\cdot& P      &\mathrel{\phantom{=}}\\
              &     & p(k-1) &  =  & p(k-2) &\cdot& P
\end{array}
\end{equation*}

\end{document}

enter image description here

egreg
  • 1,121,712