GeneralKeep lines together in \verse

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Keep lines together in \verse

Post by meho_r »

Let say that we have this case:

\begin{verse}\itshape
Line 1\\
Line 2.

Line 3\\
Line4.

Line 5\\
Line 6.
\end{verse}

The question is: how to prevent breaks at the end of page after Line 1, 3 or 5? Is there a command "keep lines together", "keep with next" or something similar?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Keep lines together in \verse

Post by localghost »

My first idea is to put the verse environment into a minipage environment.

Code: Select all

\begin{minipage}{\textwidth}
  \begin{verse}
    …
  \end{verse}
\end{minipage}

Best regards
Thorsten
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Keep lines together in \verse

Post by balf »

Try \nopagebreak; or \enlargethispage{n\baselineskip}?

B.A.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Keep lines together in \verse

Post by meho_r »

Thanks for replies, guys:) Minipage could be used, but I don't mind if there are breaks in \verse environment, just not in verses where there are only two lines. Minipage keeps together all lines and that is not what I need.

No, \nopagebreak doesn't work at this.

\enlargethispage works but I don't like using it, really. If I reorganize text, add something or change the font and \verse is moved, this added line still remains when not needed.

Is it possible that there is no command that keeps lines together?
User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Re: Keep lines together in \verse

Post by Juanjo »

The \\ command has an starred version which inhibits page breaks. So try \\* instead of \\.
balf
Posts: 158
Joined: Sat Jan 12, 2008 1:11 am

Re: Keep lines together in \verse

Post by balf »

Try
\widowpenalty=10000
\clubpenalty=10000
\raggedbottom
in your preamble; it suppresses widows and orphans.

B.A.
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Keep lines together in \verse

Post by meho_r »

Well, problem solved :D Command \\* did the trick. Thank you, Juanjo, and thank you all :)

By the way, I do use \widowpenalty10000 and \clubpenalty10000, but it doesn't work in this case. For other cases it works just fine.
Post Reply