Alternative to aligned environment for enumerate

I'm using the aligned environment within an itemize environment. I need the aligned environment so the label for the \item will be on the same line as the equation.

For example:

\begin{enumerate}
\item \begin{aligned}[t] %Big equation with many lines over two or more pages \end{aligned}
\end{enumerate}


However, I need to have this same label and equation alignment (i.e., on the same line), but also \allowdisplaybreaks for the huge equation within the aligned environment.

The problem as I understand it is that the aligned environment creates an unbreakable box around the multi-line equation. However, if I use the align environment, then the equation will not be on the same line as the \item label.

Ideas?

EDIT: Here's an MWE

\documentclass{article}
\usepackage{amsmath}
\usepackage{enumitem}

\allowdisplaybreaks[1]
\setitemize{topsep=5pt}

\begin{document}
\begin{enumerate}
\item Equation 1\\
\item Equation 2\\
\item \begin{aligned}[t] line 1&\\%This equation will span 2+ pages &line2\\ \end{aligned}
\end{enumerate}
\end{document}


In this example, line 1 is on the same line as the label (3.), but if this code were placed in the middle of a page, say, then the item in the aligned environment would start on the next page, and I need it to start right under the 2nd item.

-
Welcome to TeX.SE. I am not sure exactly what the problem is. It would be hlpeful composed a fully compilable MWE including \documentclass and the appropriate packages that reproduces the problem. –  Peter Grill May 23 '14 at 20:54
possibly not a solution to this problem, but the  \ just before the \end{aligned} will force an extra blank line (not breakable from the aligned block. and making it taller) that you don't want. –  barbara beeton May 23 '14 at 21:08
when faced with a problem like this, it kind of asks the question: can the content be redesigned? an equation that spans two pages sounds like a beast - is it absolutely necessary? could you break it down into some smaller local definitions? or perhaps a table? or an appendix? –  cmhughes May 23 '14 at 21:32
It's tough to redesign. It's for a paper, and I have a theorem that has 4 or 5 parts, and each part is a multi-line equation. I suppose I could break it up, but at minimum I'll still have a theorem with two parts, each of which will be a multi-line equation. –  Greg Doyle May 23 '14 at 21:34
Why use enumerate rather than let align number the lines? –  David Carlisle May 23 '14 at 22:23

4 Answers

The following MWE creates a mathlist that functions similar to an aligned environment:

\documentclass{article}
\usepackage[paper=a6paper]{geometry}% Just for this example
\usepackage{environ,enumitem}% http://ctan.org/pkg/environ
\makeatletter
\let\olditem\item% Store regular \item macro
\newlength{\LHS}
\def\processitem#1&#2\relax{%
\olditem\hspace*{\LHS}%
\llap{$\displaystyle #1{}$}%
$\displaystyle{}#2$%
}
\NewEnviron{mathlist}[1][3em]{%
\setlength{\LHS}{#1}% Set Left-Hand Side length
\g@addto@macro{\BODY}{\item\relax\item}% Used to delimit the items; last item identified by \item\relax\item
\def\item##1\item{% Redefine \item to capture contents
\def\optarg{##1}%
\expandafter\ifx\optarg\relax\else% Last item not reached
\expandafter\processitem##1\relax% Process item
\expandafter\item% Recursively continue processing items
\fi
}
\begin{itemize}[label={},labelsep=0pt]
\BODY% Process environment (save items)
\end{itemize}
}
\makeatother
\begin{document}
\begin{enumerate}
\item Equation 1
\item Equation 2
\item
\begin{mathlist}[1em]
\item F &= ma
\item G &= mbc
\item E &= mc^2
\item H &= md^3
\item I &= md^4
\item F &= ma
\item G &= mbc
\item E &= mc^2
\item H &= md^3
\item I &= md^4
\item F &= ma
\item G &= mbc
\item E &= mc^2
\item H &= md^3
\item I &= md^4
\item F &= ma
\item G &= mbc
\item E &= mc^2
\item H &= md^3
\item I &= md^4
\end{mathlist}
\item Equation 3
\item Equation 4
\end{enumerate}
\end{document}


\items inside mathlist are processed in a delimited requiring the use of & (it would be possible to rewrite it to work with/without).

mathlist takes a single optional argument, specifying the width of the left-hand side of equation set (default is 2em), although there are other horizontal lengths at play since you're in a list (itemize with label = {}, to be specific). mathlist uses environ in order to grab the entire environment contents, and then processes each item separately. This technique is taken from Order items in enumerate environment automatically.

In each \item inside mathlist, the math content is forced to be in \displaystyle.

-
This solution works well for my purposes, and has the added benefit of requiring much less rewriting of my paper. –  Greg Doyle May 26 '14 at 17:46

It isn't clear that you can't do something more like:

\documentclass{article}
\usepackage[leqno]{amsmath}
\usepackage{enumitem}

\allowdisplaybreaks[1]
\setitemize{topsep=5pt}

\begin{document}

\begin{align}
Equation 1\\
Equation 2\\
line 1&\\%This equation will span 2+ pages
&line2 \nonumber\\
&line2 \nonumber\\
&line2 \nonumber\\
&line2 \nonumber\\
&line2 \nonumber\\
&line2 \nonumber\\
&line2 \nonumber\\
&line2 \nonumber
\end{align}
\end{document}

-
This solution is the one I would have liked to use, but I am unable to call the [leqno] option of the amsmath package. I am not sure why, I assume it's either due to all the other packages I need, or the journal specific document class. –  Greg Doyle May 26 '14 at 17:44

One way to do this would be to pause the enumerate environment, and resume the list after the equation:

Notes:

• The paperheight=6.1cm,paperwidth=9cm were adjustments made to make the image shown here illustrate that the desired result was achieved.

Code:

\documentclass{article}
\usepackage[paperheight=5.6cm,paperwidth=9cm, showframe]{geometry}
\usepackage{amsmath}
\usepackage{enumitem}

\newcounter{TempCounter}
\newcommand{\PauseListEnvironment}{%
\stepcounter{enumi}%
\setcounter{TempCounter}{\value{enumi}}%
}%

\newcommand*{\ResumeList}{%
\makebox[\dimexpr\leftmargin\relax][r]{\arabic{TempCounter}.\hspace*{\labelsep}}%
\belowdisplayskip=0pt%
}%

\allowdisplaybreaks[1]
\setitemize{topsep=5pt}

\begin{document}
\begin{enumerate}[series=xxx]
\item Equation 1
\item Equation 2
\item Equation 3
\PauseListEnvironment%
\end{enumerate}
\begingroup
\abovedisplayskip=0pt%
\belowdisplayskip=0pt%
\begin{flalign*}\ResumeList
F &= ma &\\
G &= mbc\\
E &= mc^2 \\
H &= md^3 \\
I &= md^4
\end{flalign*}%
\endgroup%
\begin{enumerate}[resume=xxx]
\item Equation 5
\end{enumerate}
\end{document}

-

TABstacks may be the thing to assist you in this regard. They can have align or tabular like syntax, and only take up as much width as needed. Furthermore, by using understacks, the first line of equation will be aligned with the enumerator index.

As Peter Grill reminds me, any single TABstack will not break across a page boundary, because it is boxed material.

\documentclass{article}
\usepackage{tabstackengine}
\def\dfrac{\displaystyle\frac}
\stackMath
\strutlongstacks{T}
\setstacktabulargap{0pt}
\setstackgap{S}{6pt}
\begin{document}
\begin{enumerate}
\item \alignLongunderstack{
5x + 2y =& 7\\
2x  -2y =&0
}
\item \tabularShortunderstack{rrrl}{
\dfrac{1}{2}x^2 +& 3x -& 7 =& 1\\
7 x^2 -& \dfrac{3}{4} x +& 12 =& 17\\
5 x^2 +& \dfrac{2}{3} x +& 5 =& 9
}
\end{enumerate}
\end{document}


-
Does this allow the equations to span multiple pages? –  Peter Grill May 24 '14 at 2:31
@PeterGrill No, the individual tabstacks are made up of columns of boxed material. I will add that disclaimer. Thanks for the reminder. –  Steven B. Segletes May 24 '14 at 2:35