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}
The \nopagebreak command prevents LaTeX form breaking the current page at the point 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.
10.2 \newpage LaTeX's page breaks are optimized so ordinarily you only use this command in a document body to polish the final version, or inside commands. While the commands \clearpage and \cleardoublepage also end the current page, in addition they clear pending floats (see \clearpage & \cleardoublepage ).
See the FAQ: Yet another trick by Knuth is useful if you have a sequence of small blocks of text that need, individually, to be kept on their own page. Insert the command \filbreak before each small block, and the effect is achieved.
The \pagebreak command tells LaTeX to break the current page at the point of the command. With the optional argument, number , you can convert the \pagebreak command from a demand to a request.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With