Access Keys:

# 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

       \usepackage{fancyhdr}


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

	\documentclass[12pt]{article}
\usepackage{simplemargins}


you should change it to:

	\documentclass[12pt]{article}
\usepackage{simplemargins}
\pagestyle{fancy}


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

	\setlength\headrulewidth{0in}


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:

	\documentclass{article}
\pagestyle{fancy}
\begin{document}

\end{document}


This would end up looking like:

                                                        Your Name Here
6.xxx
January 31, 1990
----------------------------------------------------------------



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


## IS&T Contributions

March 31, 2015

### Get Help

Request help
from the Help Desk
Report a security incident
to the Security Team
Labels:
olc-formatting olc-formatting Delete
latex latex Delete
format format Delete