Page headers and footers in LaTeX are defined by the \pagestyle and \pagenumbering commands.

• \pagestyle defines the general contents of the headers and footers, such as where the page numbers will be printed.

• \pagenumbering defines the format of the page number.

Using the fancyhdr package, you can create customized headers and footers. I have added this to the stylesheet so it can be applied to all chapters in the project.

To customize headers and footers, you can use the fancyhdr package, which is used with the page style fancy. Rather than using the default headers and footers, fancyhdrenables custom headers and footers for odd and even pages, for chapter pages and to allow for control over font sizes, as well as much more.

The following commands defines the headers and footers of the document.

These commands are explained in the following sections.

Note: Information about the fancyhdr package is available here.

## Font definitions

In the following set of commands, the font is defined as 9 pt Helvetica using the short form phv. The text of the headers and footers use the titlepagecolor for the background.

Note that the titlepagecolor has been defined elsewhere in the stylesheet using the definecolor command.

## Injecting chapter and section text into the header

The text of a chapter heading is injected into the header using \chaptermark. \thechapter pulls in the chapter number. Similarly, the text of the section heading is pulled in using \sectionmark. The macro thesection pulls in the number of the section.

## Eliminating horizontal lines

If you don’t want to have a decorative line to separate the header from the body text, set the header and footer rule width to 0pt.

If you want the footer to have only a page number and a copyright notice on each page, use the following commands.

## Inserting fancyhead into the root file

After defining the headers and footers in the stylesheet, you insert the header into the root file after the \frontmatter environment command as follows.

Note: It is important where you place this command. The LaTeX typesetter needs to know how to build the headers and footers before any geometry is defined. After calling the \fancyhead command, you can go ahead and input your files, and so forth.

The following shows the resulting pages with headers and footers.

Sample chapter page with header and footer.

Sample even page.

Click to continue.