Section 41.4 Headers and Footers
The
titleps
package cooperates with “traditional” LaTeX divisions, such as \chapter
and \section
, and the titlesec
package, to pick up the titles of divisions automatically and migrate them to headers and footers on a page. The ps
is short for “page style”, and the documentation is a PDF file within the distribution for the titlesec
package. Primarily, we let LaTeX manage the selection of its page styles for various pages of an overall document: empty
, plain
, headings
, and myheadings
. PreTeXt does some management in the front matter. As a style writer it is not your concern where these styles are employed, but you do influence what information they contain and were it is placed on a page.Add an
<xsl:template>
to your stylesheet that begins with<xsl:template match="book" mode="titleps-style">
This would then set a collection of commands from the
titleps
package for a <book>
, which will be placed in the correct place in the LaTeX preamble. (See Section 41.8.) You can renew
existing page styles or create new
pagestyles. However you should always make your last line a declaration of the overall page style, for example,\pagestyle{headings}
Note that a book may use the empty and plain styles for some pages, so you may need to renew those styles to be harmonious with other changes you have made.
The definition of this template will override (replace) the definition given in any imported stylesheet. You can replace the value of the
@match
attribute with article
to make your style apply to a PreTeXt <article>
. If your style will be used for both books and articles, and you want the style to be identical for both, you can expand the @match
attribute to have the value article|book
. To have different styles for a book versus an article, make two separate templates.The
titleps
package allows at least twelve options per page style: even-numbered page versus odd-numbered page with two-sided printing; left, center, right; header or footer. There are semi-automatic customizable rules, variable widths allowing hanging styles, choices of marks (division at page-start versus division at page-end versus new-division-mid-page, including combinations at the same time), and more. Note that the LaTeX system of \markleft
and \markboth
has been abandonded. (Did I hear you say, “Good riddance!”?)Some care must be taken with using
\thechapter
to get the chapter number, since strange things happen in the frontmatter and backmatter, where chapters are numberless. One solution is to use \ifthechapter{}{}
which allows you to control the behavior dependent on whether there is a current chapter number. For example, if you wanted the center of the even-numbered pages to contain “Chapter 3: Derivatives” you would use\sethead[][\ifthechapter{Chapter \thechapter: }{}\chaptertitle][]{}{}{}
which would then just put “Index” in the index, and nothing at all in the preface. A similar approach could be used to deal with section numbers and titles in the case that the introduction of a chapter is multiple pages, using
\ifthesection{}{}
.Note also that the macro
\chaptertitlename
will resolve to Chapter
or Appendix
as necessary.You have attempted of activities on this page.