TransWikia.com

Priority of page breaks between paragraphs in beamer slides with allowframebreaks

TeX - LaTeX Asked by metaphori on February 14, 2021

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:

The red rectangle selects the break I would like to avoid

One Answer

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}

Answered by samcarter_is_at_topanswers.xyz on February 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP