4

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}
Werner
  • 603,163
Alex Lockwood
  • 731
  • 1
  • 8
  • 16

2 Answers2

7

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.

egreg
  • 1,121,712
1

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!

David Carlisle
  • 757,742
Mico
  • 506,678
  • 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 08 '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 08 '11 at 18:35