1
Controlling headers and footers (self.tex_typesetting)
submitted 1 year ago by estee to c/tex_typesetting

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.

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here
this post was submitted on 27 Jun 2023
1 points (100.0% liked)

TeX typesetting

150 readers
1 users here now

A place to share ideas, resources, tips, and hacks for Donald Knuths typesetting software TeX. All variants and formats like OpTeX, LaTeX and ConTeXt are welcome.

founded 1 year ago
MODERATORS