2

I want to achieve the following, except without the weird extra indentation before c.

enter image description here

Also, what's with the lack of spacing between = and b, as well as between + and d? Is there a better way to fix it than just adding \:?

Here's my code:

\begin{alignat*} {2}
a = & b + (&& c \\
&& + d) \\
& + g
\end{alignat*}

EDIT: To clarify, here's what I was looking for. I got it with daleif's solution.

enter image description here

EDIT 2: Turns out daleif's solution doesn't work with a long third line:

enter image description here

  • Try ggggggggggg\hidewidth. – GuM May 15 '15 at 13:11
  • It works! Though, it feels like a pretty ad-hoc solution, and there's probably some example where it doesn't work. Isn't there a way to do something like 123\addNewIndentation{1}456 \addNewIndentation{2}789 and then the new line \indent{1} blabla aligns with the 4 and \indent{2} blabla aligns with the 7? – Blrp May 15 '15 at 13:25
0

I'd use

\begin{alignat*} {2}
a = {}& b + (&& c \\ % <- added {}
&&& + d) \\ % <- added extra &
& + g
\end{alignat*}

Update: (please always make relevant MWEs instead of wasting peoples time). In this case (especially because it is not numbered) I'd use

\begin{align*} 
a = {}& b +
\!
\begin{aligned}[t]
  (& c \\
  & + d)
\end{aligned}
\\
& + ggggggggggggggggggggggggg
\end{align*}
  • I thought this'd work at first, but see edited OP. – Blrp May 15 '15 at 12:44
0

Is this what you require?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
a =  b &+ (c \\
& \phantom{+(c}+ d) \\
& + g
\end{align*}
\end{document}

or use this for the same output:

\begin{alignat*}{2}
 a =  b& + ( c& \\
 && + d) \\
 & + g&
\end{alignat*}  

enter image description here

  • I prefer daleif's solution, but your first solution with \phantom could be modified to give the desired output (see edited OP). – Blrp May 15 '15 at 12:12
0

Or perhaps this? It's not completely clear, actually.

\documentclass{amsart}

\begin{document}
\begin{alignat*}{2}
    a &= b&{}+ (c \\
        &&{}+ d) \\
    & + g
\end{alignat*}
\end{document}

Output:

enter image description here

Note that & should precede =, not follow it.

Post edited because of forgotten {}.

Addition:

Please don't think I'm to fussy if I insist that & shuld be placed before =: this makes the extra {} unnecessary. Input:

\documentclass{amsart}

\begin{document}
\begin{alignat*}{2}
    a &= b + (&&c \\
         &&&+ d) \\
    & {}+ g
\end{alignat*}
\end{document}

Output:

enter image description here

  • Placing & before = makes the third line appear too far to the left. – Blrp May 15 '15 at 12:48
  • @Blrp: …So, you are saying that what is wanted here is to align the + sign on the last line with the b on the first: OK, now I understand your code, I misunderstood the goal you want to achieve. – GuM May 15 '15 at 13:10

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.