Access Keys:
Skip to content (Access Key - 0)

How can I customize headers and footers in LaTeX?

It's easy to customize your page headers and footers using a set of macros available in the sipb locker. There's a couple of things you need to do to use them: the first is to add a line saying


to your preamble, somewhere after the \documentclass line. So, if you originally had


you should change it to:


The "\pagestyle{fancy}" line is very important – without it all the other commands will not have any meaning.

You also need to add the following line to your ~/.environment file:

	attach sipb
	setenv TEXINPUTS .:/mit/sipb/share/tex/macros:

Type the setenv statement just as shown, all on one line.

The header and footer fields can be defined by commands \lhead{LHEADTEXT}, \rhead{RHEADTEXT} and so on for the other fields. These commands, and all of the other commands to control the format of the headers and footers should be put before the \begin{document} line and after the \usepackage{fancyheadings} line in your file.

The page layout will be as follows:

	lhead          chead          rhead
	----------------------------------- (rule)
			page body

	----------------------------------- (rule)
	lfoot          cfoot          rfoot

The L-fields will be flushed left, the C-fields centered and the R-fields flushed right. Each of the six fields and the two "rules" (thin horizontal lines) can be defined separately. By default, all the headers and footers are empty, the bottom rule invisible, and the top rule 1/18th of an inch thick.

The thickness of the rules below the header and above the footer can be changed by redefining the length parameters \headrulewidth and \footrulewidth. These may be redefined by the \setlength command. A thickness of 0in makes the rule invisible. For example, to make the rule under the header invisible, you'd put the line


before the \begin{document} line.

If you want to have multiple lines in a header or footer, you need to separate the lines with a double backslash (\\ ). For example, if you wanted the top of every page to have your name, class, and date on separate lines, you'd use:

	\rhead{Your Name Here\\\\ \today}

	(your text here)


This would end up looking like:

                                                        Your Name Here
                                                        January 31, 1990

        (your text)

If you want to do more complex things with the headers and footers, there is a complete description of all the options available at the top of the macro file. To see it, type:

	attach sipb
	more /mit/sipb/share/tex/macros/fancyheadings.sty

IS&T Contributions

Documentation and information provided by IS&T staff members

Last Modified:

March 31, 2015

Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
olc-formatting olc-formatting Delete
latex latex Delete
format format Delete
header header Delete
footer footer Delete
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
This product/service is:
Easy to use
Difficult to use

This article is:
Adaptavist Theme Builder (4.2.3) Powered by Atlassian Confluence 3.5.13, the Enterprise Wiki