1

I'm using the titlesec package to redefine the chapter format, and I noticed a spacing issue when adding a section which causes a page break. Essentially, I want the title displayed between two horizontal lines. However, as demonstrated in the MWE below, there is an additional gap between the first line and the title if I don't manually add a \newpage right before calling the \section command.

Here's a working example:

\documentclass[11pt]{book}

\usepackage{titlesec}
\titleformat
  {\chapter}
  [display]
  {\sffamily\LARGE}
  {\filcenter\rmfamily\bfseries\fontsize{4cm}{1cm}\selectfont\thechapter}
  {6ex}
  {\titlerule\vspace{1.5ex}\filcenter}
  [\vspace{1.5ex}\titlerule]

\usepackage{lmodern}

\begin{document}

\chapter{Introduction}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce gravida nunc et
posuere condimentum. Nullam pretium, enim a iaculis vehicula, mauris dui
interdum arcu, ac egestas mi diam vitae nibh. Etiam at scelerisque ex, a
fringilla augue. Fusce leo diam, bibendum ut aliquam et, gravida at justo. Nam
rutrum augue in elit congue, vehicula tristique sem malesuada. Nulla porttitor
massa eget mollis accumsan. Aenean eu dolor ac ex congue auctor. Pellentesque
habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas. Sed et felis accumsan, congue magna eu, placerat quam. Aenean lobortis
maximus facilisis. Sed tristique vestibulum sodales. Suspendisse potenti. Nunc
eget nibh a libero dictum eleifend finibus at est. In hac habitasse platea
dictumst.

Pellentesque et tempor nisl. Proin aliquet tristique elit vitae lacinia.
Praesent accumsan nisl eu sapien sodales, ut hendrerit purus interdum. Praesent
eget viverra magna. Praesent non tincidunt neque. Vivamus fermentum maximus
porttitor. Integer vitae lacus dapibus, vulputate purus non, lacinia orci.
Aenean sodales, massa ut tincidunt iaculis, nulla velit mattis nibh, in aliquam
lectus lectus quis sapien.

% \newpage  % Commenting in this line fixes the issue.

\section{Overview}

\end{document}

I should mention that the compiler does complain about an underfull vbox which goes away if I manually break the page. Is this something that can be fixed automatically or do I have to fix such issues manually?

Edit: here's what the whole thing looks like with and without the mentioned gap. gap no gap

  • Welcome to TeX SX! What exactly are you tying to achieve? – Bernard Jan 22 '19 at 19:15
  • I've updated my post with an image demonstrating the issue I'm trying to solve. – nkoep Jan 22 '19 at 20:00
  • Add in your preamble the directive \raggedbottom. The default is \flushbottom. Also, in \fontsize, the second argument is usually 20-25% more than the first (it measures the interline skip), and usually one use points as units. – Bernard Jan 22 '19 at 20:07
  • Jepp, that did it. Also cheers for the info on the fontsize arguments. – nkoep Jan 22 '19 at 20:31
0

In twoside-mode (which is the default with book) LaTeX tries to end every page at the same vertical position. This is useful to avoid "jumping last lines".

As the height of your chapter title definition is not an integer number of heights of normal lines, LaTeX can reach this in your example only by extending existing vertical spaces. Thsi results in the extra space between the line and the heading text.

As already mentioned in a comment by Bernhard you can switch of this by using \raggedbottom. However, this would switch of the vertical flushing not only for pages with chapters but all pages. See e.g. \flushbottom vs \raggedbottom for more information. There is also a question about how to scope the \raggedbottom to one page only. And a question about why books usually use \flushbottom instead of \raggedbottom.

So, what else can be done? You can allow LaTeX to shrink or stretch specific vertical spaces by adding glue. Vertical distances (TeX calls them skips) can have additional information about allowed stretching defined by a plus-value and about shrinking defined by a minus-value. See "What is glue stretching?" for more information.

In your case you could add such glue, e.g., just after the heading before the text:

\documentclass[11pt]{book}

\usepackage{titlesec}
\titleformat
  {\chapter}
  [display]
  {\sffamily\LARGE}
  {\filcenter\rmfamily\bfseries\fontsize{4cm}{1cm}\selectfont\thechapter}
  {6ex}
  {\titlerule\vspace{1.5ex}\filcenter}
  [\vspace{1.5ex}\titlerule\vspace{0pt plus .5\baselineskip minus .5\baselineskip}]

\usepackage{lmodern}

\begin{document}

\chapter{Introduction}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce gravida nunc et
posuere condimentum. Nullam pretium, enim a iaculis vehicula, mauris dui
interdum arcu, ac egestas mi diam vitae nibh. Etiam at scelerisque ex, a
fringilla augue. Fusce leo diam, bibendum ut aliquam et, gravida at justo. Nam
rutrum augue in elit congue, vehicula tristique sem malesuada. Nulla porttitor
massa eget mollis accumsan. Aenean eu dolor ac ex congue auctor. Pellentesque
habitant morbi tristique senectus et netus et malesuada fames ac turpis
egestas. Sed et felis accumsan, congue magna eu, placerat quam. Aenean lobortis
maximus facilisis. Sed tristique vestibulum sodales. Suspendisse potenti. Nunc
eget nibh a libero dictum eleifend finibus at est. In hac habitasse platea
dictumst.

Pellentesque et tempor nisl. Proin aliquet tristique elit vitae lacinia.
Praesent accumsan nisl eu sapien sodales, ut hendrerit purus interdum. Praesent
eget viverra magna. Praesent non tincidunt neque. Vivamus fermentum maximus
porttitor. Integer vitae lacus dapibus, vulputate purus non, lacinia orci.
Aenean sodales, massa ut tincidunt iaculis, nulla velit mattis nibh, in aliquam
lectus lectus quis sapien.

\section{Overview}

\end{document}

With this, the needed extra space is added after the heading:

glue below the heading not inside the heading

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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