7

I want to get another variant for the alignment points in my question answered by Hendrik Vogt, see How to construct a long equation that is split in LHS and RHS to occupy a narrow column?.

\documentclass[twocolumn]{article}
\usepackage[a4paper,margin=1cm]{geometry}
\usepackage{amsmath}
\begin{document}
\begin{enumerate}
    \item The degree of (C) is 3.
    \item The degree of (A) is 1.
    \item%
    $\!
    \begin{aligned}[t]
      -3x(x+1)&-2x(x-1)\\
        &+4(x^2-3x-1)
                        &= \!\begin{aligned}[t]
                  &-3x^2-3x-2x^2+2x+v \\
                  &+4x^2-12x-4
               \end{aligned} \\
                        &= \!\begin{aligned}[t]
                  -3x^2-&3x-2x^2+2x+v \\
                        &+4x^2-12x-4
               \end{aligned} \\
            &= -x^2-13x-4
    \end{aligned}
    $
\end{enumerate}
\end{document}

The code above does not produce what I want to achieve as follows.

enter image description here

Note: Feel free to edit the title to be better because I have difficulty to rephrase it.

Moriambar
  • 11,466

2 Answers2

6

Since you have multiple alignment points, could use the alignedat:

enter image description here

Notes:

  • I used \rlap on the two lines so it won't effect the other alignment points.
  • The \hphantom{{}={}} was used to ensure that space was left equivalent to the =. The additional {} on either side of the equal ensures that the = is treated as a relational operator.
  • The alignedat (similar to alignat) requires information as to the number of columns. The rule of thumb is to use half the of 1 + maximum number of &s in any row (rounded up in case of fractional result). I usually just use a number that is large enough so that there are not syntax errors. Have not yet encountered a problem with using a number larger that required. But in this case it appears that 3 is enough.

References:

Code:

\documentclass[twocolumn]{article}
\usepackage[a4paper,margin=1cm]{geometry}
\usepackage{amsmath}
\begin{document}
\begin{enumerate}
    \item The degree of (C) is 3.
    \item The degree of (A) is 1.
    \item%
    $\!
    \begin{alignedat}[t]{4}
      -3x(x+1)&-2x(x-1)\\
              &+4(x^2-3x-1)
                  &&=\rlap{$-3x^2-3x-2x^2+2x+v$} \\
              &   &&\hphantom{{}={}}{+}4x^2&&-12x-4\\
              &   &&=-3x^2 &&-3x-2x^2+2x+v \\
              &   &&       &&+4x^2-12x-4 \\
              &   &&=\rlap{$-x^2-13x-4$}
    \end{alignedat}
    $
\end{enumerate}
\end{document}
Peter Grill
  • 223,288
  • 1
    Note that the spacing in the first +4x^2 on the right is not correct. – Hendrik Vogt Jan 30 '13 at 09:20
  • @HendrikVogt: Good point. I should have known that a + is not usually a unary operator. However, having the correct binary operator spacing around the operator has other consequences based on the requirement that the + and - signs be aligned as per OP's request. – Peter Grill Jan 30 '13 at 18:45
  • @GarbageCollector: Have added some info to address your question. – Peter Grill Jan 31 '13 at 00:22
3

An array provides rudimentary control over the display and alignment:

enter image description here

\documentclass[twocolumn]{article}
%\usepackage[a4paper,margin=1cm]{geometry}% http://ctan.org/pkg/geometry
%\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}
\begin{enumerate}
  \item The degree of (C) is 3.
  \item The degree of (A) is 1.
  \item $\renewcommand{\arraystretch}{1.2}
    \begin{array}[t]{@{}l@{}l}
      -3x(x+1)-2x(x-1) \\
      \phantom{-3x(x+1)}+4(x^2-3x-1)
        &{}= -3x^2-3x-2x^2+2x+v \\
        &\phantom{{}={}}{}+4x^2-12x-4 \\
        &{}=-3x^2-3x-2x^2+2x+v \\
        &\phantom{{}=-3x^2}+4x^2-12x-4 \\
        &{}= -x^2-13x-4
    \end{array}
  $
\end{enumerate}
\end{document}
Moriambar
  • 11,466
Werner
  • 603,163