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}
1

2 Answers 2

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.

1
  • 2
    ...note the optional [t] to align aligned at the top.
    – Werner
    Sep 8, 2011 at 17:49
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!

2
  • I think the problem is when the {align*} is follows an \item without any preceding text. This results in additional vertical space. Sep 8, 2011 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, 2011 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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