-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample29c-v4.tex
137 lines (102 loc) · 3.85 KB
/
example29c-v4.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
\documentclass{report}
\usepackage{lipsum}
\usepackage{boxedminipage}
\usepackage[a5paper]{geometry}
\usepackage{extramarks}[=v4]
\usepackage{ifthen}
\usepackage{fancyhdr}
\pagestyle{fancy}
\newcommand{\mysaved}{}
\fancyhead[L]{Example 29c}
\fancyhead[R]{\rightmark}
\fancyfoot[R]{\lastxmark}
\fancyhead[C]{\ifthenelse{\equal{\lastxmark}{}}
{\gdef\mysaved{}}
{\gdef\mysaved{\\[1ex]\noindent\textbf{[Continued from previous page]}}}}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrule}{}}
\newenvironment{continued}{%
\par\noindent\rule{\textwidth}{1pt}\\*
\extramarks{}{}%
\extramarks{(Continued)}{Continued on next page\ldots}%
\ignorespaces
}{%
\unskip\noindent\rule{\textwidth}{1pt}%
\extramarks{(Continued)}{}%
\extramarks{}{}%
\mysaved\par
}
\begin{document}
\pagenumbering{roman}
\tableofcontents
\thispagestyle{plain}
\noindent
\begin{boxedminipage}{\textwidth}
This is example 29c in the fancyhdr documentation.
\\[1ex]
\textbf{N.B. This version uses the old \texttt{extramarks} package, where the subsection titles in the headers are sometimes incorrect. It demonstrates the unwanted interaction between the ``extra marks'' and the normal \LaTeX{} marks. See page~3 where the header is ``1.1. THE PROBLEM'', but it should be ``1.2. EVALUATION''.}
\\[1ex]
It demonstrates the use of the \texttt{extramarks} package to implement
a ``Continued\ldots'' footer.
It defines a \texttt{continued} environment that puts \verb|\extramarks| commands around its body to force the proper footer when the body crosses a page boundary, and empty ones when it doesn't cross them.
However, in this example, the text ``Continued from previous page'' is not put in the page header, but after the block. The page header is used for normal headers. This is done by storing this text in a \emph{variable} (macro). The value is saved while the page header is formed, and uses the footer field to check if the saved value must be empty or the text ``Continued from previous page''.
\begin{verbatim}
\newcommand{\mysaved}{}
\fancyhead[L]{Example 29c}
\fancyhead[R]{\rightmark}
\fancyfoot[R]{\lastxmark}
\fancyhead[C]{\ifthenelse{\equal{\lastxmark}{}}
{\gdef\mysaved{}}
{\gdef\mysaved{\\[1ex]\noindent\textbf{[Continued
from previous page]}}}}
\fancypagestyle{plain}{%
\fancyhead{}\renewcommand{\headrule}{}}
\newenvironment{continued}{%
\par\noindent\rule{\textwidth}{1pt}\\*
\extramarks{}{}%
\extramarks{(Continued)}{Continued on next page\ldots}%
\ignorespaces
}{%
\unskip\noindent\rule{\textwidth}{1pt}%
\extramarks{(Continued)}{}%
\extramarks{}{}%
\mysaved\par
}
\end{verbatim}
\end{boxedminipage}
\pagestyle{fancy}
\newpage
\pagenumbering{arabic}
\chapter{Introduction}
\lipsum[1-4]
\section{The Problem}
\label{sec:problem}
\begin{continued}
\textbf{We want to indicate that this block of text belongs together, with
`Continued' in page footer and after the block.}
\textit{This block crosses one page boundary.}
\lipsum[2]
\textbf{Here ends the block of text that belongs together.}\\
\end{continued}
\section{Evaluation}
\lipsum[3-6]
\begin{continued}
\textbf{We want to indicate that this block of text belongs together, with
`Continued' in page footer and after the block.}
\textit{This block crosses several page boundaries.}
\lipsum[2-7]
\textbf{Here ends the block of text that belongs together.}\\
\end{continued}
Some closing text following the block.
\chapter{Another chapter}
\label{cha:another-chapter}
\lipsum[2]
\begin{continued}
\textbf{We want to indicate that this block of text belongs together, with
`Continued' in page footer and after the block.}
\textit{This block stays within a page. Therefore no header/footer.}
\textbf{Here ends the block of text that belongs together.}\\
\end{continued}
Some more text after the block.
\section{Another section}
\lipsum[3-4]
\end{document}