Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm using the scrbook class, which uses flushbottom paragraphs by default.

Usually this is OK, as a book looks better when the bottom part of the pages are aligned. But when a new section starts, a huge amount of space is inserted in the previous page to flush the bottom of the page.

Example:

\documentclass[draft=true,fontsize=10pt,pagesize,paper=148mm:215mm]{scrbook}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
  \chapter{Chapter 1}

  \section{Section 1}

  \blindtext[1]

  \blindtext[4]

  \blindtext[1]

  \blindtext[2]

  \section{Section 2}

  \blindtext[4]
\end{document}

Is there a way to use \flushbottom paragraphs by default, but \raggedbottom on pages preceding a new section?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

If you have an individual section that causes problems, you could issue \clearpage before that section. Otherwise one could try something like the plain TeX \filbreak macro. The following will push the section heading to the next page if there is less than 3cm left, and makes the previous page essentially raggedbottom, closing up so that there is at most 3cm gap at the bottom of the page.

Here section 2 causes a new page:

Before section 2

Section 2

But section 3 is placed as usual:

Section 3

\documentclass[draft=true,fontsize=10pt,pagesize,paper=148mm:215mm]{scrbook}

\usepackage[english]{babel}
\usepackage{blindtext}

\usepackage{etoolbox}
\newskip\mfilskip
\mfilskip=0pt plus 3cm\relax
\newcommand{\mfilbreak}{\vspace{\mfilskip}\penalty -200%
  \ifdim\lastskip<\mfilskip\vspace{-\lastskip}\else\vspace{-\mfilskip}\fi}
\pretocmd{\section}{\mfilbreak}{}{}

\begin{document}

\chapter{Chapter 1}

\section{Section 1}

\blindtext[1]

\blindtext[4]

\blindtext[1]

\blindtext[2]

\section{Section 2}

\blindtext[4]

\section{Section 3}

\blindtext[5]

\end{document}
share|improve this answer
    
Thanks. This works, although I had to change the "minus 3cm" part to "minus 1cm", otherwise there were places where the section heading overlapped the text before it. –  Danilo Bargen Jan 3 at 16:02
    
@DaniloBargen Thanks for pointing this out. I have now (further) updated the code so this is no longer a problem. –  Andrew Swann Jan 4 at 15:48
    
tex.stackexchange is incredible :) Thanks a lot, Andrew. –  Danilo Bargen Jan 4 at 22:32
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.