4

Source Code:

    \begin{align*}
     & = \frac{\frac{a}{c} - \frac{b}{d}}{\frac{a}{c} + \frac{b}{d}} - \frac{a-b}{a+b} & = \frac{\alpha a - b}{\alpha a + b} - \frac{a-b}{a+b}\\
      & = \frac{2(\alpha - 1)ab}{\alpha a^2+(1+\alpha)ab+b^2} & = \frac{2(\alpha - 1)}{\alpha \beta +(1+\alpha) + \frac{1}{\beta}}
\end{align*}

We can see that in the first row second column, the "=" is not aligned correctly with the second row. enter image description here

3
  • Welcome to TeX.SE.
    – Mico
    Commented Mar 20, 2021 at 8:55
  • 1
    You need &&= for the second set; and probably alignat rather than align
    – egreg
    Commented Mar 20, 2021 at 8:59
  • @egreg - I must have been reading your mind... (see below) :-)
    – Mico
    Commented Mar 20, 2021 at 9:05

1 Answer 1

6

You're not using the syntax of the align* environment correctly: If you have more than one alignment point per row and wish the material in the second group to be aligned on the = symbols instead of flush-right, you need to use &&=, not &=.

That said, I'd use an alignat* environment instead of an align* environment in order to avoid creating a needless gap between the two groups. Furthermorem, as @egreg has pointed out in a comment, there may not even be a need to align the right-hand set of equations on their = symbols -- at least not for the sample equations you provided.

enter image description here

\documentclass{article}
\usepackage{amsmath,xcolor}
\begin{document}
\textcolor{red}{incorrect}
    \begin{align*}
    &= \frac{\frac{a}{c}-\frac{b}{d}}{\frac{a}{c} + \frac{b}{d}} - \frac{a-b} {a+b} 
    &= \frac{\alpha a - b}{\alpha a + b} - \frac{a-b}{a+b}\\
    &=\frac{2(\alpha - 1)ab}{\alpha a^2+(1+\alpha)ab+b^2}
    &=\frac{2(\alpha - 1)}{\alpha \beta +(1+\alpha) + \frac{1}{\beta}}
    \end{align*}

\textcolor{red}{correct but unattractive}
    \begin{align*}
    &= \frac{\frac{a}{c}-\frac{b}{d}}{\frac{a}{c} + \frac{b}{d}} - \frac{a-b} {a+b} 
    &&= \frac{\alpha a - b}{\alpha a + b} - \frac{a-b}{a+b}\\
    &=\frac{2(\alpha - 1)ab}{\alpha a^2+(1+\alpha)ab+b^2}
    &&=\frac{2(\alpha - 1)}{\alpha \beta +(1+\alpha) + \frac{1}{\beta}}
    \end{align*}

\textcolor{red}{better: use \texttt{alignat*} instead of \texttt{align*}}
    \begin{alignat*}{2}
    &= \frac{\frac{a}{c}-\frac{b}{d}}{\frac{a}{c} + \frac{b}{d}} - \frac{a-b} {a+b} 
    &&= \frac{\alpha a - b}{\alpha a + b} - \frac{a-b}{a+b}\\
    &=\frac{2(\alpha - 1)ab}{\alpha a^2+(1+\alpha)ab+b^2}
    &&=\frac{2(\alpha - 1)}{\alpha \beta +(1+\alpha) + \frac{1}{\beta}}
    \end{alignat*}

\textcolor{red}{even better: don't align the second set of \texttt{=} symbols}
    \begin{align*}
    &= \frac{\frac{a}{c}-\frac{b}{d}}{\frac{a}{c} + \frac{b}{d}} - \frac{a-b} {a+b} 
     = \frac{\alpha a - b}{\alpha a + b} - \frac{a-b}{a+b}\\
    &=\frac{2(\alpha - 1)ab}{\alpha a^2+(1+\alpha)ab+b^2}
     =\frac{2(\alpha - 1)}{\alpha \beta +(1+\alpha) + \frac{1}{\beta}}
    \end{align*}
\end{document}
3
  • 1
    After seeing the output, I’d even avoid aligning the second set of equals signs
    – egreg
    Commented Mar 20, 2021 at 9:08
  • 1
    @egreg - I agree. :-) I've updated the answer to show how the equations look if the second set of = symbols aren't aligned.
    – Mico
    Commented Mar 20, 2021 at 9:18
  • Thanks for your answers! Great help!
    – firework
    Commented Mar 24, 2021 at 4:48

You must log in to answer this question.

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