LaTeX suppress page break
I'm trying to create a LaTex document which has a "testday" and a verse full of "testItemToDo" and I want any page break to occur before the "testday" but never between a "testday" and the verse of "testItemToDo". How can I modify my LaTex file
\documentclass{article}
\begin{document}
\LARGE
{*}{*}to do\\
\begin{verse}
{*}today\nopagebreak
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
{*}testDay\nopagebreak
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
{*}testDay\nopagebreak
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
{*}testDay\nopagebreak
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
{*}testDay\nopagebreak
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
\end{verse}
\end{document}
Surround your testday and verse with a \begin{samepage}
and \end{samepage}
, i.e.:
\begin{samepage}
{*}testDay
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
\end{samepage}
This still allows the verse to break a page fine, provided you get rid of some \\*
.
\nopagebreak[number]
The \nopagebreak
command prevents LaTeX from breaking the current page at the position of the command. With the optional argument, number, you can convert the \nopagebreak
command from a demand to a request. The number must be a number from 0 to 4. The higher the number, the more insistent the request is.
Or you can change your verse
to a minipage
... though if the list is longer than a page, latex will probably puke.
A very simple solution I've found is with \filbreak
before each (see the FAQ).
\documentclass{article}
\begin{document}
\LARGE
{*}{*}to do\\
\begin{verse}
{*}today
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
\filbreak
{*}testDay
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
\filbreak
{*}testDay
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
\filbreak
{*}testDay
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
\filbreak
{*}testDay
\begin{verse}
testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo\\*testItemToDo
\end{verse}
\end{verse}
\end{document}