Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
...and you're open for alternatives? –  Werner Jan 30 '13 at 5:38
    
@Werner: Of course but being inside the enumerate is a must. –  Oh my ghost Jan 30 '13 at 5:50
3  
Alignment of the - and + on the first RHS is incorrect. The first - is a unary operator, while + is binary. –  Werner Jan 30 '13 at 5:54

2 Answers 2

up vote 6 down vote accepted

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}
share|improve this answer
1  
Note that the spacing in the first +4x^2 on the right is not correct. –  Hendrik Vogt Jan 30 '13 at 9: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 0:22

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}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.