0

I'm using xelatex with the book class. The structure of my document is basically

\chapter{Chapter 1}

some text

\section{Section 1a}

some text

\section{Section 1b}

some text

Everything is for the most part formatted nicely, but I've got extremely inconsistent space above and below my section headings. In a few places, like the picture here, it looks terrible. How can I address this?

these are two sections

Edit: I'd linked to MWE. Since the section breaks needed sections to show the problem, my MWE was fairly long. Here is the section that was causing problems:

\titleformat{\section}[display]{\filcenter\it}{}{8ex}{\fontsize{24}{30}\selectfont}%
[\vfill]
\titlespacing{\section}{0pt}{0ex}{0ex}

The \vfill, along with \fillpage set presumably by the book documentclass, was causing the problem. The fix was to alter the second line to replace the vfill with an explicit measurement and to then set \raggedbottom.

\titleformat{\section}[display]{\filcenter\it}{}{8ex}{\fontsize{24}{30}\selectfont}%
[\vspace{20pt plus \textheight}]
\titlespacing{\section}{0pt}{0ex}{0ex}

\raggedbottom
8
  • 1
    Can you please show a complete but minimal example that gives this result? In particular, it can be interesting to know what comes on the next page.
    – mickep
    Oct 16, 2023 at 10:55
  • 1
    You presumably have a large non floating oobject on the next page that is preventing a good page break, but as you have shown no example, it is hard to help. Oct 16, 2023 at 10:57
  • @DavidCarlisle, the next page has another section. I will see if I can reproduce this at a smaller scale.
    – Shay
    Oct 16, 2023 at 11:00
  • 1
    please don't make an external link, add to your question as a code block. The question is archived forever and won't make sense without the example. Oct 16, 2023 at 11:55
  • 1
    don't ignore Package fancyhdr Warning: \headheight is too small (12.0pt): Oct 16, 2023 at 11:56

1 Answer 1

2

The standard answer is to add \raggedbottom (or if ragged bottom is not acceptable on stylistic reasons, you need to write enough words to fill the page)

However you have

\titleformat{\section}[display]{\filcenter\it}{}{8ex}{\fontsize{24}{30}\selectfont}%
[\vfill]

which adds the strongly stretchy vfill spacing after every section head, this stretches more than the space added at the bottom of a page by \raggedbottom (which is \vskip \z@ \@plus.0001fil) so all the space is stretched around section heads.

Use a finite stretch, then even the .0001fil (the smallest possible infinite stretch) added by \raggedbottom will stretch and the space around section headings will not stretch on ragged pages.

enter image description here

\titleformat{\section}[display]{\filcenter\it}{}{8ex}{\fontsize{24}{30}\selectfont}%
[\vspace{0pt plus \textheight}]
3
  • Brilliant! Thank you.
    – Shay
    Oct 16, 2023 at 14:12
  • 3
    @Shay you see why we always ask for a full example, you would never have got that answer from the original question (it would have been closed as duplicate of one of the existing questions with a "use \raggedbottom" answer:-) Oct 16, 2023 at 14:14
  • But now there isn't even a link to an example ....
    – cfr
    Oct 17, 2023 at 1:26

You must log in to answer this question.

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