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.

How do I force the following aligned output all the way to the upper left (right next to the enumerated list item)? I still want the 2nd and 3rd lines to be aligned with it's above equal sign.

\documentclass{article}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{enumerate}

\begin{document}
  \begin{enumerate}[(a)]
  \item 
    \begin{align*}
      P(A \XOR B) &= P(A)+P(B)-2P(A\cap B)
      \\ &= 0.15 + 0.10 - 0.05
      \\ &= 0.20
    \end{align*}
  \end{enumerate}
\end{document}
share|improve this question
    
Related question: mix align and enumerate –  Peter Grill Sep 8 '11 at 18:09
add comment

2 Answers 2

up vote 6 down vote accepted

align is a display math environment; use the subsidiary aligned environment, instead:

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumerate}

\begin{document}
  \begin{enumerate}[(a)]
  \item 
    $\begin{aligned}[t]
      P(A + B) &= P(A)+P(B)-2P(A\cap B)
      \\ &= 0.15 + 0.10 - 0.05
      \\ &= 0.20
    \end{aligned}$
  \end{enumerate}
\end{document}

Werner is correctly remarking the [t] that guarantees top alignment.

share|improve this answer
2  
...note the optional [t] to align aligned at the top. –  Werner Sep 8 '11 at 17:49
    
thanks a lot, man! –  Alex Lockwood Sep 8 '11 at 17:56
add comment

To use the align math environment (as well as the other equation environments of the amsmath package) but with the equations "shoved" all the way to the left, you should (i) load the amsmath package with the fleqn option and (ii) redefine the \mathindent length parameter to 0pt, as shown in the following MWE. (I've added a bit of "dummy text" to make the alignment operations a bit more easy to see.)

\documentclass{article}
\usepackage[fleqn]{amsmath}
\usepackage{enumerate,lipsum}
\setlength{\mathindent}{0pt}
\begin{document}
\noindent\lipsum[2]
  \begin{enumerate}[(a)]
  \item \lipsum[2]
    \begin{align*}
      P(A \cup B) &= P(A)+P(B)-2P(A\cap B)\\
                  &= 0.15 + 0.10 - 0.05 \\
                  &= 0.20
    \end{align*}
  \end{enumerate}
\end{document}

Hope this is what you're looking for. Happy TeXing!

share|improve this answer
    
I think the problem is when the {align*} is follows an \item without any preceding text. This results in additional vertical space. –  Peter Grill Sep 8 '11 at 18:31
    
Yeah, I wasn't quite sure if I'd understood the OP's question correctly. I thought he wanted to stick with the align* environment. –  Mico Sep 8 '11 at 18:35
add comment

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.