Skip Navigation

Controlling headers and footers

The defaults for headline and footline in plain.tex is:

\headline={\hfil}
\footline={\hss\tenrm\folio\hss}

I.e. there's no header, and in the footer the page number is printed in the center.

Many times I've found that some pages, like title pages or chapter opening pages, need exceptions from the defaults. I'd like to have a way of saying "on this page there should be neither header nor footer" or "on this page there should be a footer, but no header". Or, the header should say one thing if it's a verso page, and another if it's a recto page. In this case, we can use conditionals. They can be created like this:

\newif\iffootline \footlinetrue
\newif\ifheadline \headlinetrue

I want the default to be to print both headline and footline, so the conditionals are set to true initially.

In this case I want to control the current page only, so if the conditional is false, it needs to change back to true for the next page. For the footline, we could have this:

\footline{%
	\iffootline
		\hss\tenrm\folio\hss
	\else
		\hfil
		\global\footlinetrue	
	\fi
}

If the conditional is true, the footline is to be printed. If it's false, it prints nothing, but switches back the conditional to true for the next page.

We can do the same thing with the headline, but also add different headline texts if it's an odd or even page:

\headline{%
	\ifheadline
		\ifodd\pageno
			\hss\tenit Title\hss
		\else
			\hss\tenit Author\hss
		\fi
	\else
		\hfil
		\global\headlinetrue
	\fi
}

These conditionals can then be used in other macros, like for chapter headings, or used as they are by placing \headlinefalse and/or \footlinefalse on pages where you don't want headers and/or footers.

0
0 comments