# Preventing page break within quoting environment

I'm trying to typeset some sanskrit verses, surrounding them by a quoting environment for indentation. One line contains half a verse, the first half ended by |, the second by ||, and I would like to prevent page breaks between first and second half, so that a verse is never split over two pages.

Here's some things I tried:

\documentclass[a4paper]{memoir}
\usepackage{fontspec}
\usepackage[indentfirst=false]{quoting}
\usepackage{lipsum}
\newenvironment{absolutelynopagebreak}%See http://tex.stackexchange.com/posts/94702/edit
{\par\nobreak\vfil\penalty0\vfilneg
\vtop\bgroup}
{\par\xdef\tpd{\the\prevdepth}\egroup
\prevdepth=\tpd}
\begin{document}
\lipsum[1-4]
\begin{quoting}
xxxxx\\
aaaaaaaaaaaaaaaaaaaaaaaaaa |\\
bbbbbbbbbbbbbbbbbbbbbbbbbb ||\\
cccccccccccccccccccccccccc |\\
dddddddddddddddddddddddddd ||\\
eeeeeeeeeeeeeeeeeeeeeeeeee |\\
ffffffffffffffffffffffffff ||\\
gggggggggggggggggggggggggg |\\
hhhhhhhhhhhhhhhhhhhhhhhhhh ||\\
jjjjjjjjjjjjjjjjjjjjjjjjjj |\\
kkkkkkkkkkkkkkkkkkkkkkkkkk ||\\
%llllllllllllllllllllllllll |\\\nopagebreak%doesn't seem to be doing anything
%mmmmmmmmmmmmmmmmmmmmmmmmmm ||\\
%\begin{samepage}llllllllllllllllllllllllll |\\
%mmmmmmmmmmmmmmmmmmmmmmmmmm ||\\ \end{samepage}%doesn't seem to be doing anything either
%\begin{minipage}{\textwidth}llllllllllllllllllllllllll |\\
%mmmmmmmmmmmmmmmmmmmmmmmmmm ||\end{minipage} %works here but makes a mess in my real file
%\begin{absolutelynopagebreak}llllllllllllllllllllllllll |\\
%mmmmmmmmmmmmmmmmmmmmmmmmmm ||\\\end{absolutelynopagebreak}%breaks out of quoting's indentation, and introduces a new paragraph
llllllllllllllllllllllllll |\\
mmmmmmmmmmmmmmmmmmmmmmmmmm ||\\
nnnnnnnnnnnnnnnnnnnnnnnnnn |\\
oooooooooooooooooooooooooo ||\\

\end{quoting}
\end{document}


I know I can manually do a \newpage, but if I were to write a command/environment for each verse, which then might do some other things such as formatting, stepping up a counter etc., it could not be included and I would have to take care of the page breaks manually, which I'd of course try to avoid.

• Have you thought of using memoir's verse environment instead? – Peter Wilson Jun 19 '15 at 18:16

You can add a new key to quoting. Specifying this key should allow page breaks only at explicit paragraphs (blank lines).

\documentclass[a4paper]{memoir}
\usepackage[indentfirst=false]{quoting}
\usepackage{lipsum}

\makeatletter
\define@key{quo}{nopagebreak}[true]{\interlinepenalty=10000 }
\makeatother

\raggedbottom

\begin{document}
\lipsum[1-4]
\begin{quoting}[nopagebreak]
xxxxx\\
aaaaaaaaaaaaaaaaaaaaaaaaaa |\\
bbbbbbbbbbbbbbbbbbbbbbbbbb ||\\
cccccccccccccccccccccccccc |\\
dddddddddddddddddddddddddd ||\\
eeeeeeeeeeeeeeeeeeeeeeeeee |\\
ffffffffffffffffffffffffff ||\\
gggggggggggggggggggggggggg |\\
hhhhhhhhhhhhhhhhhhhhhhhhhh ||\\
jjjjjjjjjjjjjjjjjjjjjjjjjj |\\
kkkkkkkkkkkkkkkkkkkkkkkkkk ||\\
llllllllllllllllllllllllll |\\
mmmmmmmmmmmmmmmmmmmmmmmmmm ||\\
llllllllllllllllllllllllll |\\
mmmmmmmmmmmmmmmmmmmmmmmmmm ||\\
llllllllllllllllllllllllll |\\
mmmmmmmmmmmmmmmmmmmmmmmmmm ||\\
nnnnnnnnnnnnnnnnnnnnnnnnnn |\\
oooooooooooooooooooooooooo ||
\end{quoting}
\end{document}


I added \raggedbottom or the typesetting of the first page would be completely spoiled.

Try \\* to suppress a page break after a forced line break.

• Seems to work in my example, but doesn't seem to have any effect in my real file, unfortunately. – muk.li Jun 19 '15 at 15:06
• @muk.li Hmm... it looks that your pages do not contain strechable glue (this may happen when there are no verse breaks nor headings on the page). Make sure, that your page admits an even number of lines (either by adjusting \textheight or by adjusting the fontsize), this helps in your special situation. – jk - Reinstate Monica Jun 20 '15 at 14:48

A working solution is to put each verse in its own quoting environment, to which one adds the (conveniently global) option vskip=0cm, and which rids one of the necessity to add a manual linebreak at the end of the second half of the verse.

\documentclass[a4paper]{memoir}
\usepackage{fontspec}
\usepackage[indentfirst=false,vskip=0cm]{quoting}
\usepackage{lipsum}
\begin{document}
\lipsum[1-4]
xxxxx
\begin{quoting}
Simple letters make a very bad example. |\\
Simple letters make a very bad example. ||
\end{quoting}
\begin{quoting}
Simple letters make a very bad example. |\\
Simple letters make a very bad example. ||
\end{quoting}
\begin{quoting}
Simple letters make a very bad example. |\\
Simple letters make a very bad example. ||
\end{quoting}
\begin{quoting}
Simple letters make a very bad example. |\\
Simple letters make a very bad example. ||
\end{quoting}
\begin{quoting}
Simple letters make a very bad example. |\\
Simple letters make a very bad example. ||
\end{quoting}
\begin{quoting}
Simple letters make a very bad example. |\\
Simple letters make a very bad example. ||
\end{quoting}
\begin{quoting}
Simple letters make a very bad example. |\\
Simple letters make a very bad example. ||
\end{quoting}
\end{document}

• But, it seems if I add a footnote into a quoting environment it stops working again... – muk.li Jun 19 '15 at 17:24