3.3 Page style

The \pagestyle command sets the style throughout the document. Available options are:

• plain: Just a plain page, with numbering in the footer strip.
• empty: Produces empty header and footer lines - no page numbers.
• headings: Puts running headings on each page. The document style specifies what goes in the headings.
• myheadings: You specify what is to go in the heading with the \markboth or the \markright commands.
• fancy: from the fancyhdr package, which in turn allows for finer manipulation of the header and footer fields

\pagestyle{plain} outputs a page with just the page numbers; no headers or footers or other elements outside the text area. \pagestyle{empty} supresses even the page numbers. The empty page is therefore, an empty canvas, with no headers, footers or page numbers. \pagestyle{headings} sets the same page header on all pages, \pagestyle{myheadings} command allows what goes on the odd page heading and in the even page heading. These individual headings are specified to go in the myheading with the \markboth or the \markright commands. The \markboth command is invoked as \markboth{left head text}{right head text} whereas the \markright command only specifies the right page heading.

The code snippet below, and the output in Figure 3.3 illustrate use of \pgestyle{myheadings}. It may be noted that myheadings operates only on page headings. A more flexible way of dealing with headers and footers is in the fancyhdr package, now the standard protocol to work with headers and footers. The fancyhdr package essentially defines three placeholders, each in the header and footer strips. This gives immense flexibility to move header and footer elements around. Sec. 3.33 discusses further.

1. \documentclass[12pt,twoside,openright]{article}
2. \usepackage[margin=1in]{geometry}
3. \title{Different headers on left and right pages}
4. \usepackage{lipsum, fancyhdr}
5. \pagestyle{myheadings} %calls myheadings{x}{y}
6. \begin{document}
7. \maketitle % puts the title ‘here’, see sec 3.31
8. \markboth{Left page heading}{Right page heading}
9. \lipsum[1-3]
10. \newpage %Inserts a page break
11. \lipsum[6-11]
12. \newpage
13. \lipsum[12-15]
14. \end{document}

Figure 3.3 \pagestyle{myheadings}

Other elements in the \pagestyle include:

3.31 Title :
The content of the title is specified in the document preamble as \title{title text}, before the main body starts at \begin{document}. The title is invoked in the main body with the command \maketitle. The \maketitle command generates a title on the first/opening page in the article class and on a separate title page in the book and report classes. The command \newpage after the title page in article class is optional. A good practice is to start the main text on the next page, The following code snippet illustrates the point, and produces the output below in Fig 3.31.

1. \documentclass[12pt]{article}
2. \usepackage[margin=1in]{geometry} %margins set at 1in on all sides
3. \title{This is the title} %the content of the title; note the separation. The title text can be modified without changing the body content
4. \usepackage{lipsum} % a package of dummy text
5. \begin{document}
6. \maketitle % to call the title to be placed here
7. \lipsum[1-5] % calls para one to five of. Lipsum dummy text
8. \end{document}

Figure 3.31: \title and \maketitle

3.32 Page numbering:
The style of the page numbering can be modified with the command \pagenumbering{num_style}, where options for num-style are:

• arabic: Arabic numerals (1,2,3…)
• roman: Lowercase roman numerals (i, ii, iii, iv…very complicated)
• Roman: Uppercase roman numerals (I,II, III,IV…)
• alph: Lowercase letters (a,b,c,d…z)
• Alph: Uppercase letters (A,B,C,D…Z)

This is self explanatory. The lower case alph counter and uppercase Alph counters do not extend beyond the 26 letters in the English alphabet (a…z, A…Z). The 27th page, for instance, will not be numbered AA; it will throw a counter error. The code snippet below produces the page output in Figure 3.32.

1. \documentclass[12pt]{article}
2. \usepackage[margin=1in]{geometry}
3. \usepackage{lipsum}
4. \pagestyle{plain}
5. \pagenumbering {arabic}
6. \begin{document}
7. \begin{center}
8. \LARGE{Page with arabic numerals}\\[20pt]
9. \end{center}
10. \lipsum[1-3]
11. \newpage
12. \pagenumbering{Roman}
13. \begin{center}
14. \LARGE{Page with upper-case Roman numerals}\\[20pt]
15. \end{center}
16. \lipsum[4-7]
17. \newpage
18. \pagenumbering{alph}
19. \begin{center}
20. \LARGE{Page with lower-case alphabetic counter}\\[20pt]
21. \end{center}
22. \lipsum[8-11]
23. \newpage
24. \pagenumbering{Alph}
25. \begin{center}
26. \LARGE{Page with upper-case alphabetical counter}\\[20pt]
27. \end{center}
28. \lipsum[12-15]
29. \end{document}

Clockwise from top left: Page numbering style as arabic, Roman, uper-case alphabetical and lower-case alphabetical

Figure 3.32 Page numbering style options

3.33 Headers and Footers:
The \pagestyle and \pagenumbering commands define the default behaviour of the header and footer fields.

To recall,\pagestyle has switches
• \pagestyle{empty}: No headers or footers
• \pagestyle{plain}: No header. Footer contains page number centered horizontally;
• \pagestyle{headings}: only headers, no footer. Header contains name of chapter/section and/or subsection and page number
• \paestyle{myheadings} This is a modification of the headings option above. The change is that the header row can accommodate both the page number and user supplied text to go into the header placeholders. This is called by \pagestyle{myheadings}{markboth}{left heading text}{right heading text}. This pagestyle alsoaccepts page headers on the right page only, with the call \pagestyle{myheadings}{markright}{right page heading text}.
• \pagestyle{fancy}: allows for finer control over he header and footer fields.

The \pagestyle command has no control over the footer line which is limited to placement of page numbers and a choice of the numbering style (see Section 3.32 above).

Fancyhdr package The package fancyhdr allows for finer control of the header and footer lines. It allows for three-part placeholders in the header and footer spaces, respectively. The user-supplied text in these placeholders can be modified/structured independent of other entries. Apart from the flexibility over font sizes, families, and weights, the fancyhdr package allows for multi-line headers and footers, separate headers and footers for even and odd pages—for instance in books, where the left page is sometimes the book title and right page header is the chapter title-- etc.

The fancyhdr package is invoked in the preamble (before \begin{document}) with the command


The fancyhdr requires a modification in the pagestyle definition, which is now required as \pagestyle{fancy}. For the first page of the document, which will most probably not require headers and footers, the solution is to use the command \thispagestyle{plain} (see discussion above), which retains only the page number and no other fields in the header and footer spaces. The code snippet below produces the output in Figure 3.33. It illustrates page 1 in plain style , and a three-part placeholder setup each in the header and footer fields on page 2.

1. \documentclass[12pt]{article}
2. \usepackage[margin=1in]{geometry}
3. \usepackage{lipsum,fancyhdr}
4. \pagestyle{fancy}
5. \pagenumbering {arabic}
6. \title{Physicists Confirm Existence of Massless “Demon” Particle}
7. \begin{document}
8. \fancyhead[L]{This is the left header} %this sets the left field of the headerline
9. \fancyhead[C]{\textbf{Center text in bold}} %the center field
10. \fancyhead[R]{\textit{Right header text in italics}} %the right field
11. \fancyfoot[L]{\LARGE{Accessible Latex}} % same for footer fields
12. \fancyfoot[C]{\copyright Pradeep Raje}
13. \fancyfoot[R]{\thepage}
14. \maketitle
15. \newpage
16. \lipsum[1-4]
17. \end{document}

Figure 3.33 \pagestyle{fancy} and fancyhdr