0

I am trying to have multiple alignment in my equation in addition to line breaking. Here is a MWE illustrating my problem:

\documentclass[10pt]{article}
\usepackage[T1]{fontenc}
\usepackage{amsmath, amsthm, amssymb}
\usepackage[ansinew]{inputenc}

\begin{alignat*}{2}
a\quad &: \quad \alpha &= +1 + 2     \\
\phantom{a\quad : \quad}-3 + 4 \notag\\
a\quad &: \quad \beta &= +4
\end{alignat*}

\end{document}

The middle equation is not aligned correctly, the minus sign should of course appear right below/above the other two plus-signs.

2 Answers 2

2

Your code is not compilable (there is no \begin{document}), nor minimal (only amsmath is needed), but here is how you can do it:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\begin{alignat*}{2}
a \quad &: \quad \alpha =&& +1 + 2\\
        &                && -3 + 4\\
a \quad &: \quad \beta  =&& +4
\end{alignat*}

\end{document}

output

If you want n alignment points, you should have 2n-1 &s.

Note that there is no need for the \phantom in this case.

3
  • Thanks, it is just what I was looking for. However, if I remove the asterix, then all three equation will get an equation number. How do I make it such that only the first and last get one?
    – BillyJean
    Jun 26, 2014 at 9:32
  • 1
    @BillyJean Then you need the \noag, indeed, but I couldn't guess that from your example since you used the asterisk version of alignat. Jun 26, 2014 at 9:37
  • 1
    @SvendTveskæg -- er. that's \notag. Jun 26, 2014 at 12:34
2

Not sure of hat you want to align exactly, but it might be this (note the spacing between the signs and the figures just after the = signs). I give two ways – the last is a little simpler:

 \documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{amsmath, amssymb}

\begin{document}

\begin{alignat}{2}
a\quad &: \quad &\alpha&= +1 + 2 \\
& & &\hphantom{{}={}}{ -3} + 4 \notag\\
a\quad &: &\beta&=+4
\end{alignat}

\begin{alignat}{2}
a\quad &: \quad &\alpha&=\! \begin{aligned}[t]+1 + 2 \\
  -3 + 4
\end{aligned}\\
a\quad &: &\beta&=+4
\end{alignat}

\end{document} 

enter image description here

1
  • 1
    @BillyJean: I hadn't understood you wanted partially equation numbers. I modified my answer, and added a simpler solution.
    – Bernard
    Jun 26, 2014 at 10:00

You must log in to answer this question.

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