Styling the chapter

Monday, May 21st, 2007 | LaTeX

When we write larger works, one of the places we have the most stylistic freedom is with chapter pages. The chapter page is meant to break off the flow of pages and present something new. Looking through books on the book-case we see a wide-ranging difference in chapter styles. While the standard chapter style (as seen below) is pretty decent, there’s a long way to the chapter styles of books like Unicode Standard 5.0, A History of Mathematics, or Fundamentals of Human Neuropsychology.

Standard chapter style

There are plenty of different styles we can think up to create on our own, or by mimicking others’ designs (do note that exactly reproducing someone else’s design is probably a copyright infringement in plenty of places. Yay for copyright law). So instead of showing you just one style, I will try to explain the fundamentals of chapter styling by looking at the commands used, and then giving several examples ranging from the simple to the quite complex.

Before we continue, it would probably be prudent for me to point out that LaTeX contains two kinds of chapters: numbered (the normal chapters) and unnumbered (the table of contents, the bibliography, the index, and chapters placed in the front matter). The main difference is, of course, that numbered chapters contain the text ‘Chapter 1’ (for chapter one, obviously), and unnumbered chapters do not. At least in the default setup.

In memoir, the default numbered chapter is defined as written below (from page 86 of the manual):

\chapterheadstart
\printchaptername \chapternamenum \printchapternum
\afterchapternum
\printchaptertitle{Title goes here}
\afterchaptertitle
  

In their default definitions the print methods also make use of the following commands that define font settings: \chapenamefont, \chapnumfont, and \chaptitlefont. This information is almost all we need in order to create our own fantastic chapter styles. The last thing before we embard on experimenting with styles is to know how to create and use different chapter styles. This is accomplished using the \makechapterstyle{stylename}{commands} command, where commands is a series of redefinitions of the above-mentioned commands, and in order to use this style, we can use the command \chapterstyle{stylename}.

As a very easy beginning, let’s add some colour to the chapter style, by creating a ‘colour’ chapter style:

\usepackage{xcolor}

\makechapterstyle{colour}{
  \renewcommand*{\chapnamefont}{\normalfont\huge\bfseries\color{blue}}
  \renewcommand*{\chaptitlefont}{\normalfont\Huge\bfseries\color{blue}}
}

\chapterstyle{colour}

This style only redefines the fonts and leaves the rest of the chapter style intact as default. If we only had numbered chapters then redefining the \chapnamefont would be adequate, as the colour seeps through to the other commands, but since \chapnamefont is never called for unnumbered chapters, we also need to provide the colour for the \chaptitlefont command. For those not deeply into the LaTeX command architecture, then the star after \newcommand and \renewcommand means that the content of the command cannot contain a paragraph change, so for simple inline commands, tag the star on for verification purposes. Adding our new chapter style to our document we get the following page:

Colour chapter style

This, actually, did little to make the chapter style prettier, if I have to be a bit self-critical for a moment. Let us instead try to be a tad more artistic with our usual black and white palette. Using the tikz package that I have written about before, we can draw a black box with the chapter number inside and then have the title below, and this time let us make it right-aligned.

\usepackage{tikz}

\makechapterstyle{box}{
  \renewcommand*{\printchaptername}{}
  \renewcommand*{\chapnumfont}{\normalfont\sffamily\huge\bfseries}
  \renewcommand*{\printchapternum}{
    \flushright
    \begin{tikzpicture}
      \draw[fill,color=black] (0,0) rectangle (2cm,2cm);
      \draw[color=white] (1cm,1cm) node { \chapnumfont\thechapter };
    \end{tikzpicture}
  }
  \renewcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}
  \renewcommand*{\printchaptertitle}[1]{\flushright\chaptitlefont##1}
}

This probably requires a bit more explanation. We disable printing ‘Chapter’ for the chapter style by overriding the \printchaptername command with an empty body. Then we change the font for the chapter number to be sans-serif (\sffamily), and the same for the chapter title. Also we ensure that the chapter title is flushed right, that is it aligns to the right margin. Lastly we have the tikzpicture in the \printchapternum. Inside that we draw a black triangle that’s a 2cm square, and after that we print the chapter number in the middle of it. Fairly straightforward, eh? Using this chapter style in your document yields the following output:

Box chapter style

This is, indeed, a lot better, but there are plenty of other options for chapter styles to try out. We can combine some of the concepts in the last few chapter styles we’ve tried:

\usepackage{xcolor,calc}

\makechapterstyle{combined}{
  \setlength{\midchapskip}{-60pt}
  \setlength{\afterchapskip}{2.5cm}
  \renewcommand*{\printchaptername}{}
  \renewcommand*{\chapnumfont}{\normalfont\sffamily\bfseries\fontsize{80}{0}\selectfont}
  \renewcommand*{\printchapternum}{\flushright\chapnumfont\textcolor[rgb]{.64,.79,.87}{\thechapter}}
  \renewcommand*{\chaptitlefont}{\normalfont\sffamily\Huge\bfseries}
  \renewcommand*{\printchaptertitle}[1]{%
    \raggedright\chaptitlefont\parbox[t]{\textwidth-3cm}{\raggedright##1}}
}

\chapterstyle{combined}

First we set up some distances. The -60pt fits approximately on eye measurement the amount that you need to back up for the chapter number and title to align at the top. Normally it would be better to redefine more of the chapter style to create explicit boxes for the two things that could be top-aligned, but that’s a lot more work and would actually obscure how to use the chapter styles easily, so eye measurement it is. We make the chapter number really big (80 pt to be exact), and we print it in the RGB value (0.64, 0.79, 0.87) where colours are in [0;1] for those of mathematical inclination. Lastly we print the chapter title inside a paragraph box that is 3 cm smaller than the text width in order not to have the chapter title written on top of the chapter number as that doesn’t look particularly smashing. Adding this to our document gives us the following output:

Combined chapter style

We have now seen several different kinds of chapter styles that can be (more or less) easily customised using memoir’s functionality. Creating your own chapter style is thus just a matter of overriding a couple of methods and inserting some code. Doing this gives a tremendous difference between a cookie-cutter template of a document and a customised, personal document of high quality. For those of you who need even more examples of different chapter styles, you can refer to the Memoir Chapter Style Samples document by Lars Madsen from Århus universitets institut for matematiske fag. But the most important aspect is, of course: experiment.

In closing, these are the relevant items to override in the standard setup. You may change commands so some of them become irrelevant or not used.

  • Lengths: \beforechapskip, \midchapskip, and \afterchapskip
  • Fonts: \chapnamefont, \chapnumfont, and \chaptitlefont
  • Printing text: \printchaptername, \printchapternum, and \printchaptertitle
  • More technical surrounding blocks: \chapterheadstart, \afterchapternum, \printchapternonum, and \afterchaptertitle

For more technical details, consult the memoir manual or class file.

Tags: , , ,

13 Comments to Styling the chapter

Rodrigo
October 31, 2008

Could you help me?
I just need to change chapter style from this

Chapter 1
Introduction

to this

1 Introduction

tks

juan
July 29, 2009

I’, peruvian studiant. It’s excellent post, now my question is, if you can do the same with page numbers.

Sebastian
August 10, 2009

Very nice article! :) Do you know if \makechapterstyle works with pdflatex? When I try to compile one of your examples I always get an undefined control sequence error.

Henrik Stuart
August 10, 2009

Thank you. Styling the header and footer is detailed in my post at here.

Henrik Stuart
August 10, 2009

Thank you Sebastian. \makechapterstyle is defined in memoir (I should perhaps mention in every post that I expect people to be using this document class, but that also gets tedious). There are, of course, times when you cannot use memoir (as in having mandated a document class by someone else), but in all cases where you consider using article, book, report, or one of the other “simple” document classes, you really want to be using memoir instead as it offers you a very fine-grained control over your end result.

Martin
May 23, 2010

Thanks for ‘Styling the chapter’
I have a question: I am using this:
\makepagestyle{mystyle}
\makeheadrule{mystyle}{\textwidth}{\normalrulethickness}
\makefootrule{mystyle}{\textwidth}{\normalrulethickness}{\footruleskip}
\pagestyle{mystyle}
but page with \chapter has no additional line in header and foot. With header is ok, I do not want to have line, but line in foot is necessary. How can I add a line in foot?

Henrik Stuart
May 23, 2010

The chapter uses a separate page style called chapter (incidentally). This is normally aliased to the plain page style, i.e. there’s only a page number at the bottom of the page. You can, however, easily re-alias this to your page style using:

\aliaspagestyle{chapter}{mystyle}

Martin
May 23, 2010

Thank you for advice. I did page style for chapter and page style for other pages, I don’t know if my solution is right but it works:

For chapter page:
\makepagestyle{mychapter}
\makefootrule{mychapter}{\textwidth}{\normalrulethickness}{\footruleskip}
\makeoddfoot{mychapter}{}{\thepage}{}
\thispagestyle{mychapter} %only for this page
\aliaspagestyle{chapter}{mychapter}
For other pages:
\makepagestyle{mystyl}
\makeheadrule{mystyl}{\textwidth}{\normalrulethickness}
\makefootrule{mystyl}{\textwidth}{\normalrulethickness}{\footruleskip}
\makeoddhead{mystyl}{}{}{\small\rightmark}
\makeoddfoot{mystyl}{}{\thepage}{}
\pagestyle{mystyl}

BR

Martin
May 24, 2010

I have a qestion again:
I have choosen ger chapterstyle (\chapterstyle{ger}), but I want to change font of word ‘chapter’ on smaller and italic font.
How can I do this?

Henrik Stuart
May 25, 2010

The easy choice is probably to check the code for the ger style and copy that and rename ger to something else. Otherwise you can dig around inside memoir.cls and check what exact variables you must override in that case. You could probably get away with:

\newcommand{\setchapterstyleger}{\chapterstyle{ger}\renewcommand{\chapnamefont}{\Large\itshape}}

but I haven’t tested it.

Leanne Streja
September 23, 2010

Is there anyway to modify an individual chapter. For example, I would like chapter 3 to be chapter pi or chapter 3.14159. Is that possible?

Henrik Stuart
September 23, 2010

You can just create a custom chapterstyle and switch to it using \chapterstyle{pichapter} before your \chapter{This is my chapter 3} and then issue \chapterstyle{mydefaultstyle} afterwards.

gregthom
November 30, 2010

Hey great post! How about a chapterstyle where I have the chaptertitle and/or chapternumber on a separate recto page then empty verso page then actual chapter starts on next recto page ?
Would be glad to have some pointers. I am using memoir with default settings.

Thanks, this is for the thesis.

Leave a comment