Time for action – designing chapter and section headings

We return to our example that we used in this chapter. Our goal is to create centered headings. The font size should be smaller, further we reduce the space above and below. Finally, we switch to a sans serif font which is a good choice for bold headings:

  1. Open the file preamble.tex which we already used in this chapter. Insert this line to load the titlesec package:
    \usepackage{titlesec}
  2. Add this command to specify layout and font of the chapter headings:
    \titleformat{\chapter}[display]
      {\normalfont\sffamily\Large\bfseries\centering}
      {\chaptertitlename\ \thechapter}{0pt}{\Huge}
  3. Now define the section heading by calling \titleformat again:
    \titleformat{\section} {\normalfont\sffamily\large\bfseries\centering} ...

Get LaTeX Beginners Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.