2

I'm having a lot of troubles in aligning some terms in a complicated equation. This is probably a semi-trivial thing, but I don't get it (fssshhht!). Here's a MWE to show my problem:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{nccmath,amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}

\begin{document}

\begin{gather*}
    A + B + C + D \\[1ex]
\begin{aligned}
    &= CAT &&+ BB + CC + DD + EE 
\begin{split}
    &&- a - b - c - d \\
    &&- e - f + g \\
    &&+ h - k
\end{split} \\[1ex]
    &= FOOD,
\end{aligned}
\end{gather*}

\end{document}

The FOOD term should be aligned with the CAT term (from their equal sign), while the BB, a, e and h term should be aligned (from their front sign). Currently, this code gives a mess! What am I doing wrong here?

I tried the alignat environment, but it's worst. My troubles come from the last line, which should be aligned with the second line. Without the last line, this would be a trivial task (no need of the split environment)!

1 Answer 1

5

Does this go in the right direction?

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{nccmath,amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}

\begin{document}

\begin{gather*}
    A + B + C + D \\[1ex]
\begin{aligned}
    &= CAT \begin{aligned}[t]&+ BB + CC + DD + EE \\
    &- a - b - c - d \\
    &- e - f + g \\
    &+ h - k\end{aligned}\\
    &= FOOD,
\end{aligned}
\end{gather*}
\end{document}

enter image description here

1
  • 1
    Oh, yes, this is what I'm trying to achieve. I didn't knew that [t] trick. I'm surprised by the double aligned environments.
    – Cham
    Commented Dec 14, 2019 at 5:02

You must log in to answer this question.

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