Debian Codegraph @

texmf-dist/tex/latex/fancyhdr/fancyhdr.sty

raw
1 %%
2 %% This is file `fancyhdr.sty',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% fancyhdr.dtx (with options: `fancyhdr')
8 %%
9 %% This is a generated file.
10 %%
11 %% This file may be distributed and/or modified under the conditions of
12 %% the LaTeX Project Public License, either version 1.3 of this license
13 %% or (at your option) any later version. The latest version of this
14 %% license is in:
15 %%
16 %% http://www.latex-project.org/lppl.txt
17 %%
18 %% and version 1.3 or later is part of all distributions of LaTeX version
19 %% 2005/12/01 or later.
20 %%
21 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
22 \NeedsTeXFormat{LaTeX2e}[2018-04-01]
23 \ProvidesPackage{fancyhdr}%
24 [2025/02/07 v5.2
25 Extensive control of page headers and footers]%
26 % Copyright (C) 1994-2025 by Pieter van Oostrum <[email protected]>
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
28 \ifdefined\NewDocumentCommand\else\RequirePackage{xparse}\fi
29 \newif\iff@nch@check
30 \f@nch@checktrue
31 \DeclareOption{nocheck}{%
32 \f@nch@checkfalse
33 }
34 \let\f@nch@gbl\relax
35 \newif\iff@nch@compatViii
36 \DeclareOption{compatV3}{%
37 \PackageWarningNoLine{fancyhdr}{The `compatV3' option is deprecated.\MessageBreak
38 It will disappear in one of the following releases.\MessageBreak
39 Please change your document to work\MessageBreak
40 without this option}
41 \let\f@nch@gbl\global
42 \f@nch@compatViiitrue
43 }
44 \newif\iff@nch@twoside
45 \f@nch@twosidefalse
46 \DeclareOption{twoside}{%
47 \if@twoside\else\f@nch@twosidetrue\fi
48 }
49 \newcommand\f@nch@def[2]{%
50 \def\temp@a{#2}\ifx\temp@a\@empty\f@nch@gbl\def#1{}%
51 \else\f@nch@gbl\def#1{#2\strut}\fi}
52 \DeclareOption{myheadings}{%
53 \@ifundefined{chapter}{%
54 \def\ps@myheadings{\ps@f@nch@fancyproto \let\@mkboth\@gobbletwo
55 \fancyhf{}
56 \fancyhead[LE,RO]{\thepage}%
57 \fancyhead[RE]{\slshape\leftmark}%
58 \fancyhead[LO]{\slshape\rightmark}%
59 \let\sectionmark\@gobble
60 \let\subsectionmark\@gobble
61 }%
62 }%
63 {\def\ps@myheadings{\ps@f@nch@fancyproto \let\@mkboth\@gobbletwo
64 \fancyhf{}
65 \fancyhead[LE,RO]{\thepage}%
66 \fancyhead[RE]{\slshape\leftmark}%
67 \fancyhead[LO]{\slshape\rightmark}%
68 \let\chaptermark\@gobble
69 \let\sectionmark\@gobble
70 }%
71 }%
72 }
73 \DeclareOption{headings}{%
74 \@ifundefined{chapter}{%
75 \if@twoside
76 \def\ps@headings{\ps@f@nch@fancyproto \def\@mkboth{\protect\markboth}
77 \fancyhf{}
78 \fancyhead[LE,RO]{\thepage}%
79 \fancyhead[RE]{\slshape\leftmark}%
80 \fancyhead[LO]{\slshape\rightmark}%
81 \def\sectionmark##1{%
82 \markboth{\MakeUppercase{%
83 \ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}{}}%
84 \def\subsectionmark##1{%
85 \markright{%
86 \ifnum \c@secnumdepth >\@ne \thesubsection\quad \fi##1}}%
87 }%
88 \else
89 \def\ps@headings{\ps@f@nch@fancyproto \def\@mkboth{\protect\markboth}
90 \fancyhf{}
91 \fancyhead[LE,RO]{\thepage}%
92 \fancyhead[RE]{\slshape\leftmark}%
93 \fancyhead[LO]{\slshape\rightmark}%
94 \def\sectionmark##1{%
95 \markright {\MakeUppercase{%
96 \ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}}%
97 \let\subsectionmark\@gobble % Not needed but inserted for safety
98 }%
99 \fi
100 }{\if@twoside
101 \def\ps@headings{\ps@f@nch@fancyproto \def\@mkboth{\protect\markboth}
102 \fancyhf{}
103 \fancyhead[LE,RO]{\thepage}%
104 \fancyhead[RE]{\slshape\leftmark}%
105 \fancyhead[LO]{\slshape\rightmark}%
106 \def\chaptermark##1{%
107 \markboth{\MakeUppercase{%
108 \ifnum \c@secnumdepth >\m@ne \if@mainmatter
109 \@chapapp\ \thechapter. \ \fi\fi##1}}{}}%
110 \def\sectionmark##1{%
111 \markright {\MakeUppercase{%
112 \ifnum \c@secnumdepth >\z@ \thesection. \ \fi##1}}}%
113 }%
114 \else
115 \def\ps@headings{\ps@f@nch@fancyproto \def\@mkboth{\protect\markboth}
116 \fancyhf{}
117 \fancyhead[LE,RO]{\thepage}%
118 \fancyhead[RE]{\slshape\leftmark}%
119 \fancyhead[LO]{\slshape\rightmark}%
120 \def\chaptermark##1{%
121 \markright{\MakeUppercase{%
122 \ifnum \c@secnumdepth >\m@ne \if@mainmatter
123 \@chapapp\ \thechapter. \ \fi\fi##1}}}%
124 \let\sectionmark\@gobble % Not needed but inserted for safety
125 }%
126 \fi
127 }%
128 }
129 \ProcessOptions*
130 \newcommand{\f@nch@forc}[3]{\expandafter\f@nchf@rc\expandafter#1\expandafter{#2}{#3}}
131 \newcommand{\f@nchf@rc}[3]{\def\temp@ty{#2}\ifx\@empty\temp@ty\else
132 \f@nch@rc#1#2\f@nch@rc{#3}\fi}
133 \long\def\f@nch@rc#1#2#3\f@nch@rc#4{\def#1{#2}#4\f@nchf@rc#1{#3}{#4}}
134 \newcommand{\f@nch@for}[3]{\edef\@fortmp{#2}%
135 \expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}}
136 \newcommand\f@nch@default[3]{%
137 \edef\temp@a{\lowercase{\edef\noexpand\temp@a{#3}}}\temp@a \def#1{}%
138 \f@nch@forc\tmpf@ra{#2}%
139 {\expandafter\f@nch@ifin\tmpf@ra\temp@a{\edef#1{#1\tmpf@ra}}{}}%
140 \ifx\@empty#1\def#1{#2}\fi}
141 \newcommand{\f@nch@ifin}[4]{%
142 \edef\temp@a{#2}\def\temp@b##1#1##2\temp@b{\def\temp@b{##1}}%
143 \expandafter\temp@b#2#1\temp@b\ifx\temp@a\temp@b #4\else #3\fi}
144 \newcommand{\fancyhead}[2][]{\f@nch@fancyhf\fancyhead h[#1]{#2}}%
145 \newcommand{\fancyfoot}[2][]{\f@nch@fancyhf\fancyfoot f[#1]{#2}}%
146 \newcommand{\fancyhf}[2][]{\f@nch@fancyhf\fancyhf {}[#1]{#2}}%
147 \newcommand{\fancyheadoffset}[2][]{\f@nch@fancyhfoffs\fancyheadoffset h[#1]{#2}}%
148 \newcommand{\fancyfootoffset}[2][]{\f@nch@fancyhfoffs\fancyfootoffset f[#1]{#2}}%
149 \newcommand{\fancyhfoffset}[2][]{\f@nch@fancyhfoffs\fancyhfoffset {}[#1]{#2}}%
150 \def\f@nch@fancyhf@Echeck#1{%
151 \if@twoside\else
152 \iff@nch@twoside\else
153 \if\f@nch@@eo e%
154 \PackageWarning{fancyhdr} {\string#1's `E' option without twoside option is useless.\MessageBreak
155 Please consider using the `twoside' option}%
156 \fi\fi\fi
157 }
158 \long\def\f@nch@fancyhf#1#2[#3]#4{%
159 \def\temp@c{}%
160 \f@nch@forc\tmpf@ra{#3}%
161 {\expandafter\f@nch@ifin\tmpf@ra{eolcrhf,EOLCRHF}%
162 {}{\edef\temp@c{\temp@c\tmpf@ra}}}%
163 \ifx\@empty\temp@c\else \PackageError{fancyhdr}{Illegal char `\temp@c' in
164 \string#1 argument: [#3]}{}%
165 \fi \f@nch@for\temp@c{#3}%
166 {\f@nch@default\f@nch@@eo{eo}\temp@c
167 \f@nch@fancyhf@Echeck{#1}%
168 \f@nch@default\f@nch@@lcr{lcr}\temp@c
169 \f@nch@default\f@nch@@hf{hf}{#2\temp@c}%
170 \f@nch@forc\f@nch@eo\f@nch@@eo
171 {\f@nch@forc\f@nch@lcr\f@nch@@lcr
172 {\f@nch@forc\f@nch@hf\f@nch@@hf
173 {\expandafter\f@nch@def\csname
174 f@nch@\f@nch@eo\f@nch@lcr\f@nch@hf\endcsname {#4}}}}}}
175 \def\f@nch@fancyhfoffs#1#2[#3]#4{%
176 \def\temp@c{}%
177 \f@nch@forc\tmpf@ra{#3}%
178 {\expandafter\f@nch@ifin\tmpf@ra{eolrhf,EOLRHF}%
179 {}{\edef\temp@c{\temp@c\tmpf@ra}}}%
180 \ifx\@empty\temp@c\else \PackageError{fancyhdr}{Illegal char `\temp@c' in
181 \string#1 argument: [#3]}{}%
182 \fi \f@nch@for\temp@c{#3}%
183 {\f@nch@default\f@nch@@eo{eo}\temp@c
184 \f@nch@fancyhf@Echeck{#1}%
185 \f@nch@default\f@nch@@lcr{lr}\temp@c
186 \f@nch@default\f@nch@@hf{hf}{#2\temp@c}%
187 \f@nch@forc\f@nch@eo\f@nch@@eo
188 {\f@nch@forc\f@nch@lcr\f@nch@@lcr
189 {\f@nch@forc\f@nch@hf\f@nch@@hf
190 {\expandafter\setlength\csname
191 f@nch@offset@\f@nch@eo\f@nch@lcr\f@nch@hf\endcsname {#4}}}}}%
192 \f@nch@setoffs}
193 \NewDocumentCommand {\fancyheadwidth}{ s O{} O{} m }
194 {\f@nch@fancyhfwidth{#1}\fancyheadwidth h[#2][#3]{#4}}%
195 \NewDocumentCommand {\fancyfootwidth}{ s O{} O{} m }
196 {\f@nch@fancyhfwidth{#1}\fancyfootwidth f[#2][#3]{#4}}%
197 \NewDocumentCommand {\fancyhfwidth} { s O{} O{} m }
198 {\f@nch@fancyhfwidth{#1}\fancyhfwidth {}[#2][#3]{#4}}%
199 \def\f@nch@fancyhfwidth#1#2#3[#4][#5]#6{%
200 \setlength\@tempdima{#6}%
201 \def\temp@c{}%
202 \f@nch@forc\tmpf@ra{#4}%
203 {\expandafter\f@nch@ifin\tmpf@ra{eolcrhf,EOLCRHF}%
204 {}{\edef\temp@c{\temp@c\tmpf@ra}}}%
205 \ifx\@empty\temp@c\else \PackageError{fancyhdr}{Illegal char `\temp@c' in
206 \string#2 argument: [#4]}{}%
207 \fi
208 \f@nch@for\temp@c{#4}%
209 {\f@nch@default\f@nch@@eo{eo}\temp@c
210 \f@nch@fancyhf@Echeck{#2}%
211 \f@nch@default\f@nch@@lcr{lcr}\temp@c
212 \f@nch@default\f@nch@@hf{hf}{#3\temp@c}%
213 \f@nch@forc\f@nch@eo\f@nch@@eo
214 {\f@nch@forc\f@nch@lcr\f@nch@@lcr
215 {\f@nch@forc\f@nch@hf\f@nch@@hf
216 {%
217 \IfBooleanTF{#1}{%
218 \expandafter\edef\csname
219 f@nch@width@\f@nch@eo\f@nch@lcr\f@nch@hf\endcsname{\the\@tempdima}%
220 }%
221 {%
222 \expandafter\def\csname
223 f@nch@width@\f@nch@eo\f@nch@lcr\f@nch@hf\endcsname{#6}%
224 }%
225 \csname f@nchdrwdt@align@v@\f@nch@hf\endcsname
226 \edef\f@nch@align@@h{\f@nch@lcr}%
227 \def\temp@a{#5}%
228 \ifx\temp@a\@empty \else \f@nchdrwdt@align#5\@nil{#2}\fi
229 \expandafter\edef\csname
230 f@nch@align@\f@nch@eo\f@nch@lcr\f@nch@hf\endcsname
231 {\f@nch@align@@v\f@nch@align@@h}}}}}}
232 \def\f@nch@width@elh{\headwidth}
233 \def\f@nch@width@ech{\headwidth}
234 \def\f@nch@width@erh{\headwidth}
235 \def\f@nch@width@olh{\headwidth}
236 \def\f@nch@width@och{\headwidth}
237 \def\f@nch@width@orh{\headwidth}
238 \def\f@nch@width@elf{\headwidth}
239 \def\f@nch@width@ecf{\headwidth}
240 \def\f@nch@width@erf{\headwidth}
241 \def\f@nch@width@olf{\headwidth}
242 \def\f@nch@width@ocf{\headwidth}
243 \def\f@nch@width@orf{\headwidth}
244 \def\f@nch@align@elh{bl}
245 \def\f@nch@align@ech{bc}
246 \def\f@nch@align@erh{br}
247 \def\f@nch@align@olh{bl}
248 \def\f@nch@align@och{bc}
249 \def\f@nch@align@orh{br}
250 \def\f@nch@align@elf{tl}
251 \def\f@nch@align@ecf{tc}
252 \def\f@nch@align@erf{tr}
253 \def\f@nch@align@olf{tl}
254 \def\f@nch@align@ocf{tc}
255 \def\f@nch@align@orf{tr}
256 \def\f@nchdrwdt@align@v@h{\def\f@nch@align@@v{b}}%
257 \def\f@nchdrwdt@align@v@f{\def\f@nch@align@@v{t}}%
258 \long\def\f@nchdrwdt@align#1#2\@nil#3{%
259 \f@nch@ifin{#1}{TtcbB-}{%
260 \f@nch@ifin{#1}{-}{}{\def\f@nch@align@@v{#1}}%
261 \def\@tempa{#2}%
262 \ifx\@tempa\@empty \else \def\f@nch@align@@h{#2}\fi
263 }%
264 {\def\f@nch@align@@h{#1}}%
265 \expandafter\f@nch@ifin\expandafter{\f@nch@align@@h}{lcrj}{}%
266 {\PackageError{fancyhdr}
267 {\string#3: Illegal char `\f@nch@align@@h'\MessageBreak
268 in alignment argument}{}}%
269 }
270 \newcommand{\lhead}[2][\f@nch@olh]%
271 {\f@nch@def\f@nch@olh{#2}\f@nch@def\f@nch@elh{#1}}
272 \newcommand{\chead}[2][\f@nch@och]%
273 {\f@nch@def\f@nch@och{#2}\f@nch@def\f@nch@ech{#1}}
274 \newcommand{\rhead}[2][\f@nch@orh]%
275 {\f@nch@def\f@nch@orh{#2}\f@nch@def\f@nch@erh{#1}}
276 \newcommand{\lfoot}[2][\f@nch@olf]%
277 {\f@nch@def\f@nch@olf{#2}\f@nch@def\f@nch@elf{#1}}
278 \newcommand{\cfoot}[2][\f@nch@ocf]%
279 {\f@nch@def\f@nch@ocf{#2}\f@nch@def\f@nch@ecf{#1}}
280 \newcommand{\rfoot}[2][\f@nch@orf]%
281 {\f@nch@def\f@nch@orf{#2}\f@nch@def\f@nch@erf{#1}}
282 \newlength{\f@nch@headwidth} \let\headwidth\f@nch@headwidth
283 \newlength{\f@nch@offset@elh}
284 \newlength{\f@nch@offset@erh}
285 \newlength{\f@nch@offset@olh}
286 \newlength{\f@nch@offset@orh}
287 \newlength{\f@nch@offset@elf}
288 \newlength{\f@nch@offset@erf}
289 \newlength{\f@nch@offset@olf}
290 \newlength{\f@nch@offset@orf}
291 \newcommand{\headrulewidth}{0.4pt}
292 \newcommand{\footrulewidth}{0pt}
293 \@ifundefined{headruleskip}%
294 {\newcommand{\headruleskip}{0pt}}{}
295 \@ifundefined{footruleskip}%
296 {\newcommand{\footruleskip}{.3\normalbaselineskip}}{}
297 \newcommand{\plainheadrulewidth}{0pt}
298 \newcommand{\plainfootrulewidth}{0pt}
299 \newif\if@fancyplain \@fancyplainfalse
300 \def\fancyplain#1#2{\if@fancyplain#1\else#2\fi}
301 \headwidth=-123456789sp
302 \let\f@nch@raggedleft\raggedleft
303 \let\f@nch@raggedright\raggedright
304 \let\f@nch@centering\centering
305 \let\f@nch@everypar\everypar
306 \ifdefined\ExplSyntaxOn
307 \ExplSyntaxOn
308 \providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
309 \IfFormatAtLeastTF{2021-06-01}{
310 \def\f@nch@saveclr@parhook #1{
311 \expandafter\let\csname f@nch@__hook~#1\expandafter\endcsname
312 \csname __hook~#1\endcsname
313 \expandafter\let\csname f@nch@__hook_toplevel~#1\expandafter\endcsname
314 \csname __hook_toplevel~#1\endcsname
315 \expandafter\let\csname f@nch@__hook_next~#1\expandafter\endcsname
316 \csname __hook_next~#1\endcsname
317 \expandafter\let\csname f@nch@g__hook_#1_code_prop\expandafter\endcsname
318 \csname g__hook_#1_code_prop\endcsname
319 \RemoveFromHook{#1}[*]
320 \ClearHookNext{#1}
321 }
322 \def\f@nch@restore@parhook #1{
323 \global\expandafter\let\csname __hook~#1\expandafter\endcsname
324 \csname f@nch@__hook~#1\endcsname
325 \global\expandafter\let\csname __hook_toplevel~#1\expandafter\endcsname
326 \csname f@nch@__hook_toplevel~#1\endcsname
327 \global\expandafter\let\csname __hook_next~#1\expandafter\endcsname
328 \csname f@nch@__hook_next~#1\endcsname
329 \global\expandafter\let\csname g__hook_#1_code_prop\expandafter\endcsname
330 \csname f@nch@g__hook_#1_code_prop\endcsname
331 }
332 \def\f@nch@resetpar{
333 \f@nch@everypar{}
334 \f@nch@saveclr@parhook{para/before}
335 \f@nch@saveclr@parhook{para/begin}
336 \f@nch@saveclr@parhook{para/end}
337 \f@nch@saveclr@parhook{para/after}
338 }
339 \def\f@nch@restorepar{
340 \f@nch@restore@parhook{para/before}
341 \f@nch@restore@parhook{para/begin}
342 \f@nch@restore@parhook{para/end}
343 \f@nch@restore@parhook{para/after}
344 }
345 }{
346 \def\f@nch@resetpar{
347 \f@nch@everypar{}
348 }
349 \def\f@nch@restorepar{}
350 }
351 \ExplSyntaxOff
352 \else
353 \def\f@nch@resetpar{%
354 \f@nch@everypar{}%
355 }
356 \def\f@nch@restorepar{}
357 \fi
358 \newcommand\f@nch@noUppercase[2][]{#2}
359 \def\f@nch@reset{\f@nch@resetpar\restorecr\endlinechar=13
360 \catcode`\\=0\catcode`\{=1\catcode`\}=2\catcode`\$=3\catcode`\&=4
361 \catcode`\#=6\catcode`\^=7\catcode`\_=8\catcode`\ =10\catcode`\@=11
362 \catcode`\:=11\catcode`\~=13\catcode`\%=14
363 \catcode0=15 %NULL
364 \catcode9=10 %TAB
365 \let\\\@normalcr \let\raggedleft\f@nch@raggedleft
366 \let\raggedright\f@nch@raggedright \let\centering\f@nch@centering
367 \def\baselinestretch{1}%
368 \hsize=\headwidth
369 \def\nouppercase##1{{%
370 \let\uppercase\relax\let\MakeUppercase\f@nch@noUppercase
371 \expandafter\let\csname MakeUppercase \endcsname\relax
372 \expandafter\def\csname MakeUppercase\space\space\space\endcsname
373 [####1]####2{####2}%
374 ##1}}%
375 \@ifundefined{@normalsize} {\normalsize} % for ucthesis.cls
376 {\@normalsize}%
377 }
378 \newcommand*{\fancycenter}[1][1em]{%
379 \@ifnextchar[{\f@nch@center{#1}}{\f@nch@center{#1}[3]}%
380 }
381 \def\f@nch@center#1[#2]#3#4#5{%
382 \def\@tempa{#4}\ifx\@tempa\@empty
383 \hbox to\linewidth{\color@begingroup{#3}\hfil {#5}\color@endgroup}%
384 \else
385 \setlength\@tempdima{#1}%
386 \setlength{\@tempdimb}{#2\@tempdima}%
387 \@tempdimc \@tempdimb \advance\@tempdimc -\@tempdima
388 \setlength\@tempskipa{\@tempdimb \@plus 1fil \@minus \@tempdimc}%
389 \@tempskipb\@tempskipa
390 \def\@tempa{#3}\ifx\@tempa\@empty
391 \addtolength\@tempskipa{\z@ \@minus \@tempdima}%
392 \fi
393 \def\@tempa{#5}\ifx\@tempa\@empty % empty right
394 \addtolength\@tempskipb{\z@ \@minus \@tempdima}%
395 \fi
396 \settowidth{\@tempdimb}{#3}%
397 \settowidth{\@tempdimc}{#5}%
398 \ifdim\@tempdimb>\@tempdimc
399 \advance\@tempdimb -\@tempdimc
400 \addtolength\@tempskipb{\@tempdimb \@minus \@tempdimb}%
401 \else
402 \advance\@tempdimc -\@tempdimb
403 \addtolength\@tempskipa{\@tempdimc \@minus \@tempdimc}%
404 \fi
405 \hbox to\linewidth{\color@begingroup{#3}\hskip \@tempskipa
406 {#4}\hskip \@tempskipb {#5}\color@endgroup}%
407 \fi
408 }
409 \newcommand{\f@nch@headinit}{}
410 \newcommand{\fancyheadinit}[1]{%
411 \def\f@nch@headinit{#1}%
412 }
413 \newcommand{\f@nch@footinit}{}
414 \newcommand{\fancyfootinit}[1]{%
415 \def\f@nch@footinit{#1}%
416 }
417 \newcommand{\fancyhfinit}[1]{%
418 \def\f@nch@headinit{#1}%
419 \def\f@nch@footinit{#1}%
420 }
421 \ifdefined\NewMirroredHookPair
422 \NewMirroredHookPair{fancyhdr/before}{fancyhdr/after}
423 \NewMirroredHookPair{fancyhdr/head/begin}{fancyhdr/head/end}
424 \NewMirroredHookPair{fancyhdr/foot/begin}{fancyhdr/foot/end}
425 \fi
426 \newlength\f@nch@height
427 \newlength\f@nch@footalignment
428 \newif\iff@nch@footalign\f@nch@footalignfalse
429 \newcommand{\fancyfootalign}[1]{%
430 \def\temp@a{#1}%
431 \ifx\temp@a\@empty
432 \f@nch@footalignfalse
433 \else
434 \f@nch@footaligntrue
435 \setlength\f@nch@footalignment{#1}%
436 \fi
437 }
438 \newcommand\fancyhdrsettoheight[2]{%
439 \expandafter\ifx\csname f@nch@#2\endcsname\fancyhdrsettoheight
440 \else\PackageError{fancyhdr}{Unknown parameter #2 in \string\fancyhdrsettoheight}{}\fi
441 \setbox\@tempboxa\hbox{{\f@nch@checkfalse\csname @#2\endcsname}}%
442 \setlength{#1}\f@nch@height
443 \setbox\@tempboxa\box\voidb@x
444 }
445 \let\f@nch@oddhead\fancyhdrsettoheight
446 \let\f@nch@evenhead\fancyhdrsettoheight
447 \let\f@nch@oddfoot\fancyhdrsettoheight
448 \let\f@nch@evenfoot\fancyhdrsettoheight
449 \newcommand\f@nch@vbox[2]{%
450 \setbox0\vbox{#2}%
451 \global\f@nch@height=\ht0
452 \ifdim\ht0>#1\relax
453 \iff@nch@check
454 \dimen0=#1\advance\dimen0-\ht0
455 \PackageWarning{fancyhdr}{%
456 \string#1 is too small (\the#1): \MessageBreak
457 Make it at least \the\ht0, for example:\MessageBreak
458 \string\setlength{\string#1}{\the\ht0}%
459 \iff@nch@compatViii .\MessageBreak
460 We now make it that large for the rest of the document.\MessageBreak
461 This may cause the page layout to be inconsistent, however
462 \fi
463 \ifx#1\headheight .\MessageBreak
464 You might also make \topmargin smaller:\MessageBreak
465 \string\addtolength{\string\topmargin}{\the\dimen0}%
466 \fi
467 \@gobble
468 }%
469 \iff@nch@compatViii
470 \dimen0=#1\relax
471 \global#1=\ht0\relax
472 \ht0=\dimen0 %
473 \else
474 \ht0=#1\relax
475 \fi
476 \else
477 \ht0=#1\relax
478 \fi
479 \fi
480 \box0}
481 \newcommand\f@nch@head[6]{%
482 \f@nch@reset
483 \ifdefined\UseHook\UseHook{fancyhdr/before}\UseHook{fancyhdr/head/begin}\fi
484 \f@nch@headinit\relax
485 #1%
486 \hbox to\headwidth{%
487 \f@nch@vbox\headheight{%
488 \f@nch@hfbox{#2}{#3}{#4}{#6}{h}%
489 \vskip\headruleskip\relax
490 \headrule
491 }%
492 }%
493 #5%
494 \ifdefined\UseHook\UseHook{fancyhdr/head/end}\UseHook{fancyhdr/after}\fi
495 \f@nch@restorepar
496 }
497 \newcommand\f@nch@foot[6]{%
498 \f@nch@reset
499 \ifdefined\UseHook\UseHook{fancyhdr/before}\UseHook{fancyhdr/foot/begin}\fi
500 \f@nch@footinit\relax
501 #1%
502 \hbox to\headwidth{%
503 \f@nch@vbox\footskip{%
504 \setbox0=\vbox{\footrule}\unvbox0
505 \vskip\footruleskip
506 \f@nch@hfbox{#2}{#3}{#4}{#6}{f}%
507 \iff@nch@footalign \vskip\f@nch@footalignment \fi
508 }%
509 }%
510 #5%
511 \ifdefined\UseHook\UseHook{fancyhdr/foot/end}\UseHook{fancyhdr/after}\fi
512 \f@nch@restorepar
513 }
514 \newlength\f@nch@widthL
515 \newlength\f@nch@widthC
516 \newlength\f@nch@widthR
517 \newcommand\f@nch@hfbox[5]{%
518 \setlength\f@nch@widthL{\csname f@nch@width@#4l#5\endcsname}%
519 \setlength\f@nch@widthC{\csname f@nch@width@#4c#5\endcsname}%
520 \setlength\f@nch@widthR{\csname f@nch@width@#4r#5\endcsname}%
521 \let\@tempa\f@nch@hfbox@center
522 \ifdim \dimexpr \f@nch@widthL+\f@nch@widthC+\f@nch@widthR>\headwidth
523 \else
524 \ifdim \dimexpr \f@nch@widthL+0.5\f@nch@widthC>0.5\headwidth
525 \let \@tempa\f@nch@hfbox@fit
526 \fi
527 \ifdim \dimexpr \f@nch@widthR+0.5\f@nch@widthC>0.5\headwidth
528 \let \@tempa\f@nch@hfbox@fit
529 \fi
530 \fi
531 \@tempa{#1}{#2}{#3}#4#5%
532 }
533 \newcommand\f@nch@hfbox@center[5]{%
534 \hbox to \headwidth{%
535 \rlap{\f@nch@parbox{#1}\f@nch@widthL{#4}l{#5}}%
536 \hfill
537 \f@nch@parbox{#2}\f@nch@widthC{#4}c{#5}%
538 \hfill
539 \llap{\f@nch@parbox{#3}\f@nch@widthR{#4}r{#5}}%
540 }%
541 }
542 \newcommand\f@nch@hfbox@fit[5]{%
543 \hbox to \headwidth{%
544 \f@nch@parbox{#1}\f@nch@widthL{#4}l{#5}%
545 \hfill
546 \f@nch@parbox{#2}\f@nch@widthC{#4}c{#5}%
547 \hfill
548 \f@nch@parbox{#3}\f@nch@widthR{#4}r{#5}%
549 }%
550 }%
551 \newcommand\f@nch@parbox[5]{%
552 \expandafter\expandafter\expandafter\f@nch@parbox@align
553 \csname f@nch@align@#3#4#5\endcsname
554 \parbox[\f@nch@align@@v]{#2}%
555 {%
556 \f@nch@align@@pre
557 \f@nch@align@@h\leavevmode\ignorespaces#1%
558 \f@nch@align@@post
559 }%
560 }
561 \newcommand\f@nch@parbox@align[2]{%
562 \def\f@nch@align@@pre{}%
563 \def\f@nch@align@@post{}%
564 \csname f@nch@parbox@align@v#1\endcsname
565 \csname f@nch@parbox@align@h#2\endcsname
566 }
567 \def\f@nch@parbox@align@vT{\def\f@nch@align@@v{t}\def\f@nch@align@@pre{\vspace{0pt}}}
568 \def\f@nch@parbox@align@vt{\def\f@nch@align@@v{t}}
569 \def\f@nch@parbox@align@vc{\def\f@nch@align@@v{c}}
570 \def\f@nch@parbox@align@vb{\def\f@nch@align@@v{b}}
571 \def\f@nch@parbox@align@vB{\def\f@nch@align@@v{b}\def\f@nch@align@@post{\vspace{0pt}}}
572 \def\f@nch@parbox@align@hl{\def\f@nch@align@@h{\raggedright}}
573 \def\f@nch@parbox@align@hc{\def\f@nch@align@@h{\centering}}
574 \def\f@nch@parbox@align@hr{\def\f@nch@align@@h{\raggedleft}}
575 \def\f@nch@parbox@align@hj{\def\f@nch@align@@h{}}
576 \@ifundefined{@chapapp}{\let\@chapapp\chaptername}{}%
577 \def\f@nch@initialise{%
578 \@ifundefined{chapter}%
579 {\def\sectionmark##1{\markboth{\MakeUppercase{\ifnum \c@secnumdepth>\z@
580 \thesection\hskip 1em\relax
581 \fi ##1}}{}}%
582 \def\subsectionmark##1{\markright {\ifnum \c@secnumdepth >\@ne
583 \thesubsection\hskip 1em\relax \fi ##1}}}%
584 {\def\chaptermark##1{\markboth {\MakeUppercase{\ifnum
585 \c@secnumdepth>\m@ne \@chapapp\ \thechapter. \ \fi ##1}}{}}%
586 \def\sectionmark##1{\markright{\MakeUppercase{\ifnum \c@secnumdepth >\z@
587 \thesection. \ \fi ##1}}}%
588 }%
589 \def\headrule{{\if@fancyplain\let\headrulewidth\plainheadrulewidth\fi
590 \hrule\@height\headrulewidth\@width\headwidth
591 \vskip-\headrulewidth}}%
592 \def\footrule{{\if@fancyplain\let\footrulewidth\plainfootrulewidth\fi
593 \hrule\@width\headwidth\@height\footrulewidth}}%
594 \def\headrulewidth{0.4pt}%
595 \def\footrulewidth{0pt}%
596 \def\headruleskip{0pt}%
597 \def\footruleskip{0.3\normalbaselineskip}%
598 \fancyhf{}%
599 \if@twoside
600 \fancyhead[el,or]{\fancyplain{}{\slshape\rightmark}}%
601 \fancyhead[er,ol]{\fancyplain{}{\slshape\leftmark}}%
602 \else
603 \fancyhead[l]{\fancyplain{}{\slshape\rightmark}}%
604 \fancyhead[r]{\fancyplain{}{\slshape\leftmark}}%
605 \fi
606 \fancyfoot[c]{\rmfamily\thepage}% page number
607 }
608 \f@nch@initialise
609 \def\ps@f@nch@fancyproto{%
610 \ifdim\headwidth<0sp
611 \global\advance\headwidth123456789sp\global\advance\headwidth\textwidth
612 \fi
613 \gdef\ps@f@nch@fancyproto{\@fancyplainfalse\ps@f@nch@fancycore}%
614 \@fancyplainfalse\ps@f@nch@fancycore
615 }%
616 \@namedef{f@nch@ps@f@nch@fancyproto-is-fancyhdr}{}
617 \def\ps@fancy{\ps@f@nch@fancyproto}
618 \@namedef{f@nch@ps@fancy-is-fancyhdr}{}
619 \def\ps@fancyplain{\ps@f@nch@fancyproto \let\ps@plain\ps@plain@fancy}
620 \def\ps@plain@fancy{\@fancyplaintrue\ps@f@nch@fancycore}
621 \let\f@nch@ps@empty\ps@empty
622 \def\ps@f@nch@fancycore{%
623 \f@nch@ps@empty
624 \def\@mkboth{\protect\markboth}%
625 \def\f@nch@oddhead{\f@nch@head\f@nch@Oolh\f@nch@olh\f@nch@och\f@nch@orh\f@nch@Oorh{o}}%
626 \def\@oddhead{%
627 \iff@nch@twoside
628 \ifodd\c@page
629 \f@nch@oddhead
630 \else
631 \@evenhead
632 \fi
633 \else
634 \f@nch@oddhead
635 \fi
636 }
637 \def\f@nch@oddfoot{\f@nch@foot\f@nch@Oolf\f@nch@olf\f@nch@ocf\f@nch@orf\f@nch@Oorf{o}}%
638 \def\@oddfoot{%
639 \iff@nch@twoside
640 \ifodd\c@page
641 \f@nch@oddfoot
642 \else
643 \@evenfoot
644 \fi
645 \else
646 \f@nch@oddfoot
647 \fi
648 }
649 \def\@evenhead{\f@nch@head\f@nch@Oelh\f@nch@elh\f@nch@ech\f@nch@erh\f@nch@Oerh{e}}%
650 \def\@evenfoot{\f@nch@foot\f@nch@Oelf\f@nch@elf\f@nch@ecf\f@nch@erf\f@nch@Oerf{e}}%
651 }
652 \def\f@nch@Oolh{\if@reversemargin\hss\else\relax\fi}
653 \def\f@nch@Oorh{\if@reversemargin\relax\else\hss\fi}
654 \let\f@nch@Oelh\f@nch@Oorh
655 \let\f@nch@Oerh\f@nch@Oolh
656 \let\f@nch@Oolf\f@nch@Oolh
657 \let\f@nch@Oorf\f@nch@Oorh
658 \let\f@nch@Oelf\f@nch@Oelh
659 \let\f@nch@Oerf\f@nch@Oerh
660 \def\f@nch@offsolh{\headwidth=\textwidth\advance\headwidth\f@nch@offset@olh
661 \advance\headwidth\f@nch@offset@orh\hskip-\f@nch@offset@olh}
662 \def\f@nch@offselh{\headwidth=\textwidth\advance\headwidth\f@nch@offset@elh
663 \advance\headwidth\f@nch@offset@erh\hskip-\f@nch@offset@elh}
664 \def\f@nch@offsolf{\headwidth=\textwidth\advance\headwidth\f@nch@offset@olf
665 \advance\headwidth\f@nch@offset@orf\hskip-\f@nch@offset@olf}
666 \def\f@nch@offself{\headwidth=\textwidth\advance\headwidth\f@nch@offset@elf
667 \advance\headwidth\f@nch@offset@erf\hskip-\f@nch@offset@elf}
668 \def\f@nch@setoffs{%
669 \f@nch@gbl\let\headwidth\f@nch@headwidth
670 \f@nch@gbl\def\f@nch@Oolh{\f@nch@offsolh}%
671 \f@nch@gbl\def\f@nch@Oelh{\f@nch@offselh}%
672 \f@nch@gbl\def\f@nch@Oorh{\hss}%
673 \f@nch@gbl\def\f@nch@Oerh{\hss}%
674 \f@nch@gbl\def\f@nch@Oolf{\f@nch@offsolf}%
675 \f@nch@gbl\def\f@nch@Oelf{\f@nch@offself}%
676 \f@nch@gbl\def\f@nch@Oorf{\hss}%
677 \f@nch@gbl\def\f@nch@Oerf{\hss}%
678 }
679 \newif\iff@nch@footnote
680 \AtBeginDocument{%
681 \let\latex@makecol\@makecol
682 \def\@makecol{\ifvoid\footins\f@nch@footnotefalse\else\f@nch@footnotetrue\fi
683 \let\f@nch@topfloat\@toplist\let\f@nch@botfloat\@botlist\latex@makecol}%
684 }
685 \newcommand\iftopfloat[2]{\ifx\f@nch@topfloat\@empty #2\else #1\fi}%
686 \newcommand\ifbotfloat[2]{\ifx\f@nch@botfloat\@empty #2\else #1\fi}%
687 \newcommand\iffloatpage[2]{\if@fcolmade #1\else #2\fi}%
688 \newcommand\iffootnote[2]{\iff@nch@footnote #1\else #2\fi}%
689 \ifx\@temptokenb\undefined \csname newtoks\endcsname\@temptokenb\fi
690 \newif\iff@nch@pagestyle@star
691 \newcommand\fancypagestyle{%
692 \@ifstar{\f@nch@pagestyle@startrue\f@nch@pagestyle}%
693 {\f@nch@pagestyle@starfalse\f@nch@pagestyle}%
694 }
695 \newcommand\f@nch@pagestyle[1]{%
696 \@ifnextchar[{\f@nch@@pagestyle{#1}}{\f@nch@@pagestyle{#1}[f@nch@fancyproto]}%
697 }
698 \long\def\f@nch@@pagestyle#1[#2]#3{%
699 \@ifundefined{ps@#2}{%
700 \PackageError{fancyhdr}{\string\fancypagestyle: Unknown base page style `#2'}{}%
701 }{%
702 \@ifundefined{f@nch@ps@#2-is-fancyhdr}{%
703 \PackageError{fancyhdr}{\string\fancypagestyle: Base page style `#2' is not fancyhdr-based}{}%
704 }%
705 {%
706 \f@nch@pagestyle@setup
707 \def\temp@b{\@namedef{ps@#1}}%
708 \expandafter\temp@b\expandafter{\the\@temptokenb
709 \let\f@nch@gbl\relax\@nameuse{ps@#2}#3\relax}%
710 \@namedef{f@nch@ps@#1-is-fancyhdr}{}%
711 }%
712 }%
713 }
714 \newcommand\f@nch@pagestyle@setup{%
715 \iff@nch@pagestyle@star
716 \iff@nch@check\@temptokenb={\f@nch@checktrue}\else\@temptokenb={\f@nch@checkfalse}\fi
717 \@tfor\temp@a:=
718 \f@nch@olh\f@nch@och\f@nch@orh\f@nch@elh\f@nch@ech\f@nch@erh
719 \f@nch@olf\f@nch@ocf\f@nch@orf\f@nch@elf\f@nch@ecf\f@nch@erf
720 \f@nch@width@elh\f@nch@width@ech\f@nch@width@erh\f@nch@width@olh
721 \f@nch@width@och\f@nch@width@orh\f@nch@width@elf\f@nch@width@ecf
722 \f@nch@width@erf\f@nch@width@olf\f@nch@width@ocf\f@nch@width@orf
723 \f@nch@align@elh\f@nch@align@ech\f@nch@align@erh\f@nch@align@olh
724 \f@nch@align@och\f@nch@align@orh\f@nch@align@elf\f@nch@align@ecf
725 \f@nch@align@erf\f@nch@align@olf\f@nch@align@ocf\f@nch@align@orf
726 \f@nch@Oolh\f@nch@Oorh\f@nch@Oelh\f@nch@Oerh
727 \f@nch@Oolf\f@nch@Oorf\f@nch@Oelf\f@nch@Oerf
728 \f@nch@headinit\f@nch@footinit
729 \headrule\headrulewidth\footrule\footrulewidth
730 \do {%
731 \toks@=\expandafter\expandafter\expandafter{\temp@a}%
732 \toks@=\expandafter\expandafter\expandafter{%
733 \expandafter\expandafter\expandafter\def
734 \expandafter\expandafter\temp@a\expandafter{\the\toks@}}%
735 \edef\temp@b{\@temptokenb={\the\@temptokenb\the\toks@}}%
736 \temp@b
737 }%
738 \@tfor\temp@a:=
739 \f@nch@offset@olh\f@nch@offset@orh\f@nch@offset@elh\f@nch@offset@erh
740 \f@nch@offset@olf\f@nch@offset@orf\f@nch@offset@elf\f@nch@offset@erf
741 \do {%
742 \toks@=\expandafter\expandafter\expandafter{\expandafter\the\temp@a}%
743 \toks@=\expandafter\expandafter\expandafter{%
744 \expandafter\expandafter\expandafter\setlength
745 \expandafter\expandafter\temp@a\expandafter{\the\toks@}}%
746 \edef\temp@b{\@temptokenb={\the\@temptokenb\the\toks@}}%
747 \temp@b
748 }%
749 \else
750 \@temptokenb={}%
751 \fi
752 }
753 \newcommand\fancypagestyleassign[2]{%
754 \@ifundefined{ps@#2}{%
755 \PackageError{fancyhdr}{\string\fancypagestyleassign: Unknown page style `#2'}{}%
756 }{%
757 \expandafter\let
758 \csname ps@#1\expandafter\endcsname
759 \csname ps@#2\endcsname
760 \@ifundefined{f@nch@ps@#2-is-fancyhdr}{%
761 \expandafter\let\csname f@nch@ps@#1-is-fancyhdr\endcsname\@undefined
762 }{%
763 \@namedef{f@nch@ps@#1-is-fancyhdr}{}%
764 }%
765 }%
766 }
767 \fancypagestyle*{fancydefault}{\f@nch@initialise}
768 \def\f@nchdrbox@topstrut{\vrule height\ht\strutbox width\z@}
769 \def\f@nchdrbox@botstrut{\vrule depth\dp\strutbox width\z@}
770 \def\f@nchdrbox@nostrut{\noalign{\vspace{0pt}}\let\f@nchdrbox@@crstrut\f@nchdrbox@botstrut}
771 \NewDocumentCommand{\fancyhdrbox}{ O{cl} o m }{%
772 \begingroup
773 \let\f@nchdrbox@@pre\f@nchdrbox@topstrut
774 \let\f@nchdrbox@@postx\f@nchdrbox@botstrut
775 \let\f@nchdrbox@@posty\relax
776 \let\f@nchdrbox@@crstrut\strut
777 \IfNoValueTF{#2}%
778 {\let\f@nchdrbox@@halignto\@empty}%
779 {\setlength\@tempdima{#2}%
780 \def\f@nchdrbox@@halignto{to\@tempdima}}%
781 \def\@tempa{#1}%
782 \ifx\@tempa\@empty
783 \f@nchdrbox@align cl\@nil{#3}%
784 \else
785 \f@nchdrbox@align #1\@nil{#3}%
786 \fi
787 \endgroup
788 }
789 \protected\def\f@nchdrbox@cr{%
790 {\ifnum0=`}\fi\@ifstar\@f@nchdrbox@xcr\@f@nchdrbox@xcr}
791
792 \def\@f@nchdrbox@xcr{%
793 \unskip\f@nchdrbox@@crstrut
794 \@ifnextchar[\@f@nchdrbox@argc{\ifnum0=`{\fi}\cr}%
795 }
796
797 \def\@f@nchdrbox@argc[#1]{%
798 \ifnum0=`{\fi}%
799 \ifdim #1>\z@
800 \unskip\@f@nchdrbox@xargc{#1}%
801 \else
802 \@f@nchdrbox@yargc{#1}%
803 \fi}
804
805 \def\@f@nchdrbox@xargc#1{\@tempdima #1\advance\@tempdima \dp \strutbox
806 \vrule \@height\z@ \@depth\@tempdima \@width\z@ \cr}
807
808 \def\@f@nchdrbox@yargc#1{\cr\noalign{\setlength\@tempdima{#1}\vskip\@tempdima}}
809 \def\f@nchdrbox@T{\let\f@nchdrbox@@pre\f@nchdrbox@nostrut
810 \f@nchdrbox@t}
811 \def\f@nchdrbox@t{\def\f@nchdrbox@@v{t}\def\f@nchdrbox@@h{l}}
812 \def\f@nchdrbox@c{\def\f@nchdrbox@@v{c}\def\f@nchdrbox@@h{c}}
813 \def\f@nchdrbox@b{\def\f@nchdrbox@@v{b}\def\f@nchdrbox@@h{l}}
814 \def\f@nchdrbox@B{\let\f@nchdrbox@@postx\relax
815 \def\f@nchdrbox@@posty{\vspace{0pt}}%
816 \f@nchdrbox@b}
817 \long\def\f@nchdrbox@align#1#2\@nil#3{%
818 \f@nch@ifin{#1}{TtcbB}{%
819 \@nameuse{f@nchdrbox@#1}%
820 \def\@tempa{#2}%
821 \ifx\@tempa\@empty\else \def\f@nchdrbox@@h{#2}\fi
822 }%
823 {\def\f@nchdrbox@@v{c}\def\f@nchdrbox@@h{#1}}%
824 \expandafter\f@nch@ifin\expandafter{\f@nchdrbox@@h}{lcr}{}%
825 {\PackageError{fancyhdr}{\string\fancyhdrbox: Illegal char `\f@nchdrbox@@h'\MessageBreak
826 in alignment argument}{}}%
827 \let\\\f@nchdrbox@cr
828 \setbox0=\if \f@nchdrbox@@v t\vtop
829 \else \vbox
830 \fi
831 {%
832 \ialign \f@nchdrbox@@halignto
833 \bgroup \relax
834 {\if \f@nchdrbox@@h l\hskip 1sp\else \hfil \fi
835 \ignorespaces ##\unskip
836 \if\f@nchdrbox@@h r\else \hfil \fi
837 }%
838 \tabskip\z@skip \cr
839 \f@nchdrbox@@pre
840 #3\unskip \f@nchdrbox@@postx
841 \crcr
842 \egroup
843 \f@nchdrbox@@posty
844 }%
845 \if\f@nchdrbox@@v c\@tempdima=\ht0\advance\@tempdima\dp0%
846 \ht0=0.5\@tempdima\dp0=0.5\@tempdima\fi
847 \leavevmode \box0
848 }
849 \@ifclassloaded{newlfm}
850 {
851 \let\ps@@empty\f@nch@ps@empty
852 \AtBeginDocument{%
853 \renewcommand{\@zfancyhead}[5]{\relax\hbox to\headwidth{\f@nch@reset
854 \@zfancyvbox\headheight{\hbox
855 {\rlap{\parbox[b]{\headwidth}{\raggedright\f@nch@olh}}\hfill
856 \parbox[b]{\headwidth}{\centering\f@nch@olh}\hfill
857 \llap{\parbox[b]{\headwidth}{\raggedleft\f@nch@orh}}}%
858 \zheadrule}}\relax}%
859 }
860 }
861 {}
862 \endinput
863 %%
864 %% End of file `fancyhdr.sty'.