-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample22.tex
71 lines (53 loc) · 1.68 KB
/
example22.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
\documentclass[openany]{book}
\usepackage{lipsum}
\usepackage{ifthen}
\usepackage{lastpage}
\usepackage{refcount}
\usepackage{boxedminipage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyfoot[C]{\thepage\ of \pageref{LastPage}}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrule}{}}
\fancyfoot[R]{%
\ifthenelse{\isodd{\value{page}} \and
\not \( \value{page}=\getpagerefnumber{LastPage} \) }%
{Please turn over}{}%
}
\begin{document}
\tableofcontents
\bigskip
\noindent
\begin{boxedminipage}{\textwidth}
This is example 22 in the fancyhdr documentation.
We use the page number style ``n of m'' where ``m'' is the number of pages. This is done using the \texttt{lastpage} package. As we want the same style on chapter opening pages, and others that use the \texttt{plain} page style, we redefine the \texttt{plain} page style with \verb|\fancypagestyle|.
To get all this working you usually have to do one additional \LaTeX{} run.
\begin{verbatim}
\usepackage{lastpage}
\usepackage{refcount}
. . .
\fancyfoot[C]{\thepage\ of \pageref{LastPage}}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrule}{}}
\end{verbatim}
This example also puts ``Please turn over'' in the righthand side footer on odd pages, except the last page. This is done with the following code:
\begin{verbatim}
\usepackage{ifthen}
. . .
\fancyfoot[R]{%
\ifthenelse{\isodd{\value{page}} \and
\not \( \value{page}=\getpagerefnumber{LastPage} \) }%
{Please turn over}{}%
}
\end{verbatim}
\end{boxedminipage}
\chapter{Introduction}
\lipsum
\section{The Problem}
\label{sec:problem}
\lipsum[1]
\section{Evaluation}
\lipsum
Some more text.
Some more text.
Some more text.
Some more text.
\end{document}