Home General LaTeX tips and tricks → Section title font [Previous Page] [Question index] [Next Page]

12. How do you replace the section title font?


Answer

Use the sectsty package by Rebecca and Rowland McDonnell.

It's not that I don't like Computer Modern as a font for chapter and (sub)-section titles, but it is a very wide font, and for longer titles it will extend into the margin or onto a second line, which looks very ugly. Also, using a sans-serif font for titles adds a little variety to the text without compromising legibility.


Example usage

In the preamble:


\usepackage{sectsty}
\allsectionsfont{\usefont{OT1}{phv}{bc}{n}\selectfont}

In the manuscript:


... introduce our own entry in the field: the \rotan{} system.


\section{Compiling Sequential Programming Languages}

Figure~\ref{fig:compilation-path} shows the traditional compilation
path on sequential architectures for ...


Result, before

'Before' screenshot

Result, after

'After' screenshot

Things to watch out for

The phv used in the \usefont{} command above is the encoded name for the Helvetica-Narrow font. All PostScript fonts can be referred to by such “Berry names”, after Karl Berry who first proposed this scheme. Of course whether or not this will have any effect depends on whether you have the font installed to begin with.

Figuring out this sort of thing is the kind of voodoo that can make LaTeX so daunting at times, especially since there does not seem to be a whole lot of tutorial information on this on the web or in the (teTeX) documentation. This is why I recommend Kopka's A Guide to LaTeX so strongly: it has a wonderful section on LaTeX font handling, which contains amongst other things a good explanation of the \usefont{} command and a table with the Barry encodings for all the standard PostScript fonts.


[Previous page] [Question index] [Next page]

Leo Breebaart (leo@lspace.org)
Last updated: 27 June 2016