# Keeping equations as part of a paragraph on the same page

I want to have equations with item lists as part of a paragraph such that there is no page break between the equation and the item list, but there can be a page break in the middle of the paragraph.

Currently I am using:

\def\formula#1#2{
\begin{samepage}
\begin{align}
#1
\end{align}  where
\begin{itemize}
#2
\end{itemize}
\end{samepage}
}


For example used like The formula is given by: \formula{f(x)=x^2}{\item $x$ is some variable}.

However, this seems to cause the whole paragraph it is used in not to have a page break.

I've tried using the minipage environment, but that causes the minipage to start where the line ended; it is shifted to the right so that part of the sentence after which the formula started was printed to its left. Introducing a line break (\\*) between the sentence and the formula then causes errors, since I sometimes do use the command as a separate paragraph, in which case there is no line to end.

I've also tried \nopagebreak[4], but that didn't seem to do anything at all.

How can I keep the equation and the itemize on the same page without necessarily having the whole paragraph on that page as well?

-
I've tried using the minipage environment... OK, do start before this environment by \par command. – wipet Jun 8 '14 at 12:04

## 1 Answer

\documentclass[a5paper]{article}
\usepackage{amsmath}
\def\formula#1#2{\par\noindent%
\minipage{\linewidth}\noindent
\belowdisplayskip=0pt
\belowdisplayshortskip=0pt
\begin{align}
#1
\intertext{%
\parbox[t]{\linewidth}{%
where  \\[-\normalbaselineskip]
\begin{itemize}
#2
\end{itemize}\vspace{-\normalbaselineskip}}}\nonumber
\end{align}
\endminipage
}

\begin{document}
Lorem ipsum dolorsitamet, consecteturadipisicingelit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minimveniam, exercitationullamcolaborisnisi ut aliquipexeacommodoconsequat. Duisautereprehenderit in voluptatevelit esse cillumdolore eu fugiatnullapariatur. Occaecatcupidatat non proident, sunt in culpa quiofficiadeseruntmollit.
\formula{f(x) &= x^2}{\item $x$ is some variable}
Lorem ipsum dolorsitamet, consecteturadipisicingelit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minimveniam, exercitationullamcolaborisnisi ut aliquipexeacommodoconsequat. Duisautereprehenderit in voluptatevelit esse cillumdolore eu fugiatnullapariatur. Occaecatcupidatat non proident, sunt in culpa quiofficiadeseruntmollit.

\end{document}

-
Seems to be working wuite well, but when the formula is long (even at half the line width) the item list is shifted to the left, sometimes even off the page! – Angelorf Jun 8 '14 at 13:50
Putting the parbox inside the equation (align) makes the positioning of the parbox dependant on the length of the formula. Therefore when the formula is long, and centered in the middle, the parbox creates a box with a width equal to linewidth, but such that its middle coincides with the start of the equation. It ends up with half the item list off the left hand side of the page. – Angelorf Jun 8 '14 at 13:58
see my edited answer – Herbert Jun 8 '14 at 14:18
Works pretty nice. However I am getting page breaks at some places. The breaks occur before the 'where'. – Angelorf Jun 8 '14 at 18:52
@Angelorf -- to quote from the texbook, p.189: "Plain TeX sets \predisplaypenalty=10000, because fine printers traditionally shun displayed formulas at the very top of a page." that is what forces the last line of a paragraph preceding a display over to the following page. one can change it, but it's considered bad style. – barbara beeton Jun 9 '14 at 14:45