1

MWE

\documentclass[paper=a4]{scrartcl}
\usepackage{lipsum}
\begin{document}
    \section{a}
    \lipsum[1-2]
    \section{b}
    \lipsum[3-4]
    \subsection{c}
    \lipsum[5]
\end{document}

The example above will break the paragraph in the subsection c in half.

Page breaking results

I would like latex to, when it needs a page break,

  • Break at the subsection level(or whatever the deepest sectioning level in that location was)
  • If there are multiple subsections on that page and breaking at that level will make the document require another break at a paragraph later on(because it would shift everything), try to break at an upper level(section, subsection) instead.

Is there a package or a configuration setting that would supply this algorithm? Or if I were to place pagebreak commands in some clever way, would it achieve this effect, semi-automatically?

Or in other words, I want latex to leave space at the bottom instead of splitting paragraphs, and I am also wondering if it can be clever about this by breaking a section early to avoid having to break a subsection later on. The latter part is also important, only achieving the former is relatively easy.

I know that I can do this by inserting a \newpage etc. above the \subsection{c} line, I am not looking for the plain breaks.

Please feel free to share a solution even if it is specific to a rendering engine or a different latex implementation.

Thanks in advance.

0

1 Answer 1

1

You can avoid having a paragraph split with the \interlinepenalty. I just added one line to your example:

\documentclass[paper=a4]{scrartcl}
\interlinepenalty=10000
\usepackage{lipsum}
\begin{document}
    \section{a}
    \lipsum[1-2]
    \section{b}
    \lipsum[3-4]
    \subsection{c}
    \lipsum[5]
\end{document}
3
  • @JohnKormylo Are you sure that \raggedbottom changes penalties and not only "stretches" glue?
    – Keks Dose
    Commented May 7, 2019 at 14:36
  • Actually, I suspect that \raggedbottom is the default for scrartcl class. It seems to have no effect whatsoever. Commented May 7, 2019 at 14:38
  • Hey, thanks for the answer. It works indeed. Now I uninstalled tex for an irrelevant reason(will install it back) so I can't test it and thought I should ask it instead of creating a duplicate question later on. Does this work fine with the lists(itemize, enum) and other kinds of elements as well, for example lstlisting? Or does one need to do something else for these elements to break completely instead of partially as well? If so, is there a quick solution for these too? Thanks :) (edit, sorry I can't upvote because I don't have the 15rep but I marked it as the answer)
    – Lacey
    Commented May 7, 2019 at 17:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .