# Priority of page breaks between paragraphs in beamer slides with allowframebreaks

I have breamer slides with allowframebreaks which have some basic structure, e.g.:

\begin{frame}[fragile,allowframebreaks]{Title}

some text...
\begin{itemize}...\end{itemize}

other text
\begin{itemize}...\end{itemize}

another text
\begin{lstlisting}...\end{lstlisting}

\end{frame}


I don't want that my content get broken between text and the list/code that follows (though, it might be ok to break a list or a lstlisting). In other words, I would like to break with highest priority between paragraphs. Of course, I do not want to use explicit \framebreaks.

I tried putting \nopagebreak between the text part and the itemize/lstlisting that follows but it does not seem to work. Also, I would not like to wrap them in \minipage, since I would like to not clutter the code (also, using a command may have issues with listings). Hence, an "automatic" configuration would the best for me.

Any suggestion?

MWE

\documentclass[9pt]{beamer}

\usepackage{lipsum}
\usepackage{listings}

\begin{document}

\begin{frame}[fragile,allowframebreaks]{Title}

abcdef\\
ghilmn\\
pqrst
\begin{lstlisting}
a
b
c
d
e
f
\end{lstlisting}

abcdef\\
ghilmn\\
pqrst
\begin{lstlisting}
a
b
c
\end{lstlisting}

some text 1
\begin{lstlisting}
a
b
c
d
\end{lstlisting}

uvz\\
123\\
456
\begin{lstlisting}
a
b
c
\end{lstlisting}

uvz\\
123\\
456
\begin{lstlisting}
a
b
c
\end{lstlisting}

some text 2
\begin{itemize}
\item a
\item b
\item c
\end{itemize}

\end{frame}

\end{document}


And what I do NOT want is the part highlighted in the figure that follows:

• Can you make a minimal working example (MWE) that reproduces your problem? – user36296 Oct 23 '18 at 8:47
• Yes. I updated the post. – metaphori Oct 23 '18 at 9:29
• You can make something unbreakable by putting it into a minipage {\linewidth}. OTOH, lstlisting is sensitive and may need to be put into a savebox first. – John Kormylo Oct 23 '18 at 14:17
• @JohnKormylo as I wrote in the post, I would not like to use them because it would clutter the code and they need to be manually inserted everywhere.. I was looking for an automated way to express breakability. I think the reference atomic unit should be the "paragraph": cannot break a paragraph, only between paragraphs. This would not be optimal since that would require paragraphs shorter than a framer, but would still be better than other solutions. – metaphori Oct 23 '18 at 14:20
• You could certainly redefine lstlisting to be unbreakable, but that won't include the "some text 1" etc. How is LaTeX supposed to know where you want the pagebreaks unless you tell it? Besides, one shouldn't use page breaks in a beamer presentation at all (style wise). – John Kormylo Oct 23 '18 at 14:29

You can influence the breaks point by manually using \framebreak before your "some text":

\documentclass[9pt]{beamer}

\usepackage{lipsum}
\usepackage{listings}

\begin{document}

\begin{frame}[fragile,allowframebreaks]{Title}

abcdef\\
ghilmn\\
pqrst
\begin{lstlisting}
a
b
c
d
e
f
\end{lstlisting}

abcdef\\
ghilmn\\
pqrst
\begin{lstlisting}
a
b
c
\end{lstlisting}

\framebreak
some text 1
\begin{lstlisting}
a
b
c
d
\end{lstlisting}

uvz\\
123\\
456
\begin{lstlisting}
a
b
c
\end{lstlisting}

uvz\\
123\\
456
\begin{lstlisting}
a
b
c
\end{lstlisting}

\framebreak
some text 2
\begin{itemize}
\item a
\item b
\item c
\end{itemize}

\end{frame}

\end{document}


With a bit of luck reducing fraction of filled frame might also influence the breaking point, but you have to be lucky to find a value that works for all slides. Here one that works for the first slide:

\documentclass[9pt]{beamer}

\usepackage{lipsum}
\usepackage{listings}

\begin{document}

\begin{frame}[fragile,allowframebreaks=0.80]{Title}

abcdef\\
ghilmn\\
pqrst
\begin{lstlisting}
a
b
c
d
e
f
\end{lstlisting}

abcdef\\
ghilmn\\
pqrst
\begin{lstlisting}
a
b
c
\end{lstlisting}

some text 1
\begin{lstlisting}
a
b
c
d
\end{lstlisting}

uvz\\
123\\
456
\begin{lstlisting}
a
b
c
\end{lstlisting}

uvz\\
123\\
456
\begin{lstlisting}
a
b
c
\end{lstlisting}

some text 2
\begin{itemize}
\item a
\item b
\item c
\end{itemize}

\end{frame}

\end{document}

• Sorry, I did not specify that I would not like to use explicit framebreaks. I'll update the question. – metaphori Oct 23 '18 at 9:37