-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample26G.tex
91 lines (65 loc) · 2.21 KB
/
example26G.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
\documentclass[a4paper]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead[C]{Normal Header}
\usepackage{lipsum}
\fancypagestyle{Special}{
% setting the header in beginning of environment
\fancyhead[C]{Special Header}
}%
\newenvironment{Special}[1]{%
\pagestyle{Special}%
\section*{Special Environment (#1)}
}{%
}
\begin{document}
This is example 26G in the \texttt{fancyhdr} documentation. It
demonstrates the use of a different page style inside an
environment. When the environment ends, the page style is reset to the
page style outside of the environment by the \TeX{} grouping mechanism.
If we don't take measures, the page style of the last page will not be
the one that we set inside the environment. The \LaTeX{} code used is:
\begin{verbatim}
\fancypagestyle{Special}{
% setting the header in beginning of environment
\fancyhead[C]{Special Header}
}%
\newenvironment{Special}[1]{%
\pagestyle{Special}%
\section*{Special Environment #1}
}{%
}
\end{verbatim}
\begin{Special}{a}
{\itshape\lipsum}
\bigskip
{\bfseries Now here the environment ends before a \verb|\newpage| is
given, so the page style will be reset to the one that was current
outside of the environment and this page gets the wrong header (Normal
Header).}
\end{Special}
\clearpage
\begin{Special}{b}
{\itshape\lipsum}
\bigskip
{\bfseries Here we give an \verb|\clearpage| at the end of the
environment, so that the last page of the environment will get the
Special page style.}
\clearpage
\end{Special}
\begin{Special}{c}
{\itshape\lipsum}
\bigskip
{\bfseries Here we give a \verb|\thispagestyle{Special}| at the end of
the environment, so that the last page of the environment still gets
the special page style. However, this requires that the
\texttt{Special} pagestyle is defined outside of the environment, as
is done in this example. However if the special page style was defined
inside the environment, it will have disappeared at the end of the
page, and \LaTeX{} will silently ignore it. It doesn't even give an
error message. The following pages will get the Normal header again.}
\thispagestyle{Special}
\end{Special}
\section*{This text is outside the \texttt{Special} environment}
\lipsum
\end{document}