Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

fancyhdr.sty 20 KB

You have to be logged in to leave a comment. Sign In
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
  1. % fancyhdr.sty version 3.2
  2. % Fancy headers and footers for LaTeX.
  3. % Piet van Oostrum,
  4. % Dept of Computer and Information Sciences, University of Utrecht,
  5. % Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands
  6. % Telephone: +31 30 2532180. Email: piet@cs.uu.nl
  7. % ========================================================================
  8. % LICENCE:
  9. % This file may be distributed under the terms of the LaTeX Project Public
  10. % License, as described in lppl.txt in the base LaTeX distribution.
  11. % Either version 1 or, at your option, any later version.
  12. % ========================================================================
  13. % MODIFICATION HISTORY:
  14. % Sep 16, 1994
  15. % version 1.4: Correction for use with \reversemargin
  16. % Sep 29, 1994:
  17. % version 1.5: Added the \iftopfloat, \ifbotfloat and \iffloatpage commands
  18. % Oct 4, 1994:
  19. % version 1.6: Reset single spacing in headers/footers for use with
  20. % setspace.sty or doublespace.sty
  21. % Oct 4, 1994:
  22. % version 1.7: changed \let\@mkboth\markboth to
  23. % \def\@mkboth{\protect\markboth} to make it more robust
  24. % Dec 5, 1994:
  25. % version 1.8: corrections for amsbook/amsart: define \@chapapp and (more
  26. % importantly) use the \chapter/sectionmark definitions from ps@headings if
  27. % they exist (which should be true for all standard classes).
  28. % May 31, 1995:
  29. % version 1.9: The proposed \renewcommand{\headrulewidth}{\iffloatpage...
  30. % construction in the doc did not work properly with the fancyplain style.
  31. % June 1, 1995:
  32. % version 1.91: The definition of \@mkboth wasn't restored on subsequent
  33. % \pagestyle{fancy}'s.
  34. % June 1, 1995:
  35. % version 1.92: The sequence \pagestyle{fancyplain} \pagestyle{plain}
  36. % \pagestyle{fancy} would erroneously select the plain version.
  37. % June 1, 1995:
  38. % version 1.93: \fancypagestyle command added.
  39. % Dec 11, 1995:
  40. % version 1.94: suggested by Conrad Hughes <chughes@maths.tcd.ie>
  41. % CJCH, Dec 11, 1995: added \footruleskip to allow control over footrule
  42. % position (old hardcoded value of .3\normalbaselineskip is far too high
  43. % when used with very small footer fonts).
  44. % Jan 31, 1996:
  45. % version 1.95: call \@normalsize in the reset code if that is defined,
  46. % otherwise \normalsize.
  47. % this is to solve a problem with ucthesis.cls, as this doesn't
  48. % define \@currsize. Unfortunately for latex209 calling \normalsize doesn't
  49. % work as this is optimized to do very little, so there \@normalsize should
  50. % be called. Hopefully this code works for all versions of LaTeX known to
  51. % mankind.
  52. % April 25, 1996:
  53. % version 1.96: initialize \headwidth to a magic (negative) value to catch
  54. % most common cases that people change it before calling \pagestyle{fancy}.
  55. % Note it can't be initialized when reading in this file, because
  56. % \textwidth could be changed afterwards. This is quite probable.
  57. % We also switch to \MakeUppercase rather than \uppercase and introduce a
  58. % \nouppercase command for use in headers. and footers.
  59. % May 3, 1996:
  60. % version 1.97: Two changes:
  61. % 1. Undo the change in version 1.8 (using the pagestyle{headings} defaults
  62. % for the chapter and section marks. The current version of amsbook and
  63. % amsart classes don't seem to need them anymore. Moreover the standard
  64. % latex classes don't use \markboth if twoside isn't selected, and this is
  65. % confusing as \leftmark doesn't work as expected.
  66. % 2. include a call to \ps@empty in ps@@fancy. This is to solve a problem
  67. % in the amsbook and amsart classes, that make global changes to \topskip,
  68. % which are reset in \ps@empty. Hopefully this doesn't break other things.
  69. % May 7, 1996:
  70. % version 1.98:
  71. % Added % after the line \def\nouppercase
  72. % May 7, 1996:
  73. % version 1.99: This is the alpha version of fancyhdr 2.0
  74. % Introduced the new commands \fancyhead, \fancyfoot, and \fancyhf.
  75. % Changed \headrulewidth, \footrulewidth, \footruleskip to
  76. % macros rather than length parameters, In this way they can be
  77. % conditionalized and they don't consume length registers. There is no need
  78. % to have them as length registers unless you want to do calculations with
  79. % them, which is unlikely. Note that this may make some uses of them
  80. % incompatible (i.e. if you have a file that uses \setlength or \xxxx=)
  81. % May 10, 1996:
  82. % version 1.99a:
  83. % Added a few more % signs
  84. % May 10, 1996:
  85. % version 1.99b:
  86. % Changed the syntax of \f@nfor to be resistent to catcode changes of :=
  87. % Removed the [1] from the defs of \lhead etc. because the parameter is
  88. % consumed by the \@[xy]lhead etc. macros.
  89. % June 24, 1997:
  90. % version 1.99c:
  91. % corrected \nouppercase to also include the protected form of \MakeUppercase
  92. % \global added to manipulation of \headwidth.
  93. % \iffootnote command added.
  94. % Some comments added about \@fancyhead and \@fancyfoot.
  95. % Aug 24, 1998
  96. % version 1.99d
  97. % Changed the default \ps@empty to \ps@@empty in order to allow
  98. % \fancypagestyle{empty} redefinition.
  99. % Oct 11, 2000
  100. % version 2.0
  101. % Added LPPL license clause.
  102. %
  103. % A check for \headheight is added. An errormessage is given (once) if the
  104. % header is too large. Empty headers don't generate the error even if
  105. % \headheight is very small or even 0pt.
  106. % Warning added for the use of 'E' option when twoside option is not used.
  107. % In this case the 'E' fields will never be used.
  108. %
  109. % Mar 10, 2002
  110. % version 2.1beta
  111. % New command: \fancyhfoffset[place]{length}
  112. % defines offsets to be applied to the header/footer to let it stick into
  113. % the margins (if length > 0).
  114. % place is like in fancyhead, except that only E,O,L,R can be used.
  115. % This replaces the old calculation based on \headwidth and the marginpar
  116. % area.
  117. % \headwidth will be dynamically calculated in the headers/footers when
  118. % this is used.
  119. %
  120. % Mar 26, 2002
  121. % version 2.1beta2
  122. % \fancyhfoffset now also takes h,f as possible letters in the argument to
  123. % allow the header and footer widths to be different.
  124. % New commands \fancyheadoffset and \fancyfootoffset added comparable to
  125. % \fancyhead and \fancyfoot.
  126. % Errormessages and warnings have been made more informative.
  127. %
  128. % Dec 9, 2002
  129. % version 2.1
  130. % The defaults for \footrulewidth, \plainheadrulewidth and
  131. % \plainfootrulewidth are changed from \z@skip to 0pt. In this way when
  132. % someone inadvertantly uses \setlength to change any of these, the value
  133. % of \z@skip will not be changed, rather an errormessage will be given.
  134. % March 3, 2004
  135. % Release of version 3.0
  136. % Oct 7, 2004
  137. % version 3.1
  138. % Added '\endlinechar=13' to \fancy@reset to prevent problems with
  139. % includegraphics in header when verbatiminput is active.
  140. % March 22, 2005
  141. % version 3.2
  142. % reset \everypar (the real one) in \fancy@reset because spanish.ldf does
  143. % strange things with \everypar between << and >>.
  144. \def\ifancy@mpty#1{\def\temp@a{#1}\ifx\temp@a\@empty}
  145. \def\fancy@def#1#2{\ifancy@mpty{#2}\fancy@gbl\def#1{\leavevmode}\else
  146. \fancy@gbl\def#1{#2\strut}\fi}
  147. \let\fancy@gbl\global
  148. \def\@fancyerrmsg#1{%
  149. \ifx\PackageError\undefined
  150. \errmessage{#1}\else
  151. \PackageError{Fancyhdr}{#1}{}\fi}
  152. \def\@fancywarning#1{%
  153. \ifx\PackageWarning\undefined
  154. \errmessage{#1}\else
  155. \PackageWarning{Fancyhdr}{#1}{}\fi}
  156. % Usage: \@forc \var{charstring}{command to be executed for each char}
  157. % This is similar to LaTeX's \@tfor, but expands the charstring.
  158. \def\@forc#1#2#3{\expandafter\f@rc\expandafter#1\expandafter{#2}{#3}}
  159. \def\f@rc#1#2#3{\def\temp@ty{#2}\ifx\@empty\temp@ty\else
  160. \f@@rc#1#2\f@@rc{#3}\fi}
  161. \def\f@@rc#1#2#3\f@@rc#4{\def#1{#2}#4\f@rc#1{#3}{#4}}
  162. % Usage: \f@nfor\name:=list\do{body}
  163. % Like LaTeX's \@for but an empty list is treated as a list with an empty
  164. % element
  165. \newcommand{\f@nfor}[3]{\edef\@fortmp{#2}%
  166. \expandafter\@forloop#2,\@nil,\@nil\@@#1{#3}}
  167. % Usage: \def@ult \cs{defaults}{argument}
  168. % sets \cs to the characters from defaults appearing in argument
  169. % or defaults if it would be empty. All characters are lowercased.
  170. \newcommand\def@ult[3]{%
  171. \edef\temp@a{\lowercase{\edef\noexpand\temp@a{#3}}}\temp@a
  172. \def#1{}%
  173. \@forc\tmpf@ra{#2}%
  174. {\expandafter\if@in\tmpf@ra\temp@a{\edef#1{#1\tmpf@ra}}{}}%
  175. \ifx\@empty#1\def#1{#2}\fi}
  176. %
  177. % \if@in <char><set><truecase><falsecase>
  178. %
  179. \newcommand{\if@in}[4]{%
  180. \edef\temp@a{#2}\def\temp@b##1#1##2\temp@b{\def\temp@b{##1}}%
  181. \expandafter\temp@b#2#1\temp@b\ifx\temp@a\temp@b #4\else #3\fi}
  182. \newcommand{\fancyhead}{\@ifnextchar[{\f@ncyhf\fancyhead h}%
  183. {\f@ncyhf\fancyhead h[]}}
  184. \newcommand{\fancyfoot}{\@ifnextchar[{\f@ncyhf\fancyfoot f}%
  185. {\f@ncyhf\fancyfoot f[]}}
  186. \newcommand{\fancyhf}{\@ifnextchar[{\f@ncyhf\fancyhf{}}%
  187. {\f@ncyhf\fancyhf{}[]}}
  188. % New commands for offsets added
  189. \newcommand{\fancyheadoffset}{\@ifnextchar[{\f@ncyhfoffs\fancyheadoffset h}%
  190. {\f@ncyhfoffs\fancyheadoffset h[]}}
  191. \newcommand{\fancyfootoffset}{\@ifnextchar[{\f@ncyhfoffs\fancyfootoffset f}%
  192. {\f@ncyhfoffs\fancyfootoffset f[]}}
  193. \newcommand{\fancyhfoffset}{\@ifnextchar[{\f@ncyhfoffs\fancyhfoffset{}}%
  194. {\f@ncyhfoffs\fancyhfoffset{}[]}}
  195. % The header and footer fields are stored in command sequences with
  196. % names of the form: \f@ncy<x><y><z> with <x> for [eo], <y> from [lcr]
  197. % and <z> from [hf].
  198. \def\f@ncyhf#1#2[#3]#4{%
  199. \def\temp@c{}%
  200. \@forc\tmpf@ra{#3}%
  201. {\expandafter\if@in\tmpf@ra{eolcrhf,EOLCRHF}%
  202. {}{\edef\temp@c{\temp@c\tmpf@ra}}}%
  203. \ifx\@empty\temp@c\else
  204. \@fancyerrmsg{Illegal char `\temp@c' in \string#1 argument:
  205. [#3]}%
  206. \fi
  207. \f@nfor\temp@c{#3}%
  208. {\def@ult\f@@@eo{eo}\temp@c
  209. \if@twoside\else
  210. \if\f@@@eo e\@fancywarning
  211. {\string#1's `E' option without twoside option is useless}\fi\fi
  212. \def@ult\f@@@lcr{lcr}\temp@c
  213. \def@ult\f@@@hf{hf}{#2\temp@c}%
  214. \@forc\f@@eo\f@@@eo
  215. {\@forc\f@@lcr\f@@@lcr
  216. {\@forc\f@@hf\f@@@hf
  217. {\expandafter\fancy@def\csname
  218. f@ncy\f@@eo\f@@lcr\f@@hf\endcsname
  219. {#4}}}}}}
  220. \def\f@ncyhfoffs#1#2[#3]#4{%
  221. \def\temp@c{}%
  222. \@forc\tmpf@ra{#3}%
  223. {\expandafter\if@in\tmpf@ra{eolrhf,EOLRHF}%
  224. {}{\edef\temp@c{\temp@c\tmpf@ra}}}%
  225. \ifx\@empty\temp@c\else
  226. \@fancyerrmsg{Illegal char `\temp@c' in \string#1 argument:
  227. [#3]}%
  228. \fi
  229. \f@nfor\temp@c{#3}%
  230. {\def@ult\f@@@eo{eo}\temp@c
  231. \if@twoside\else
  232. \if\f@@@eo e\@fancywarning
  233. {\string#1's `E' option without twoside option is useless}\fi\fi
  234. \def@ult\f@@@lcr{lr}\temp@c
  235. \def@ult\f@@@hf{hf}{#2\temp@c}%
  236. \@forc\f@@eo\f@@@eo
  237. {\@forc\f@@lcr\f@@@lcr
  238. {\@forc\f@@hf\f@@@hf
  239. {\expandafter\setlength\csname
  240. f@ncyO@\f@@eo\f@@lcr\f@@hf\endcsname
  241. {#4}}}}}%
  242. \fancy@setoffs}
  243. % Fancyheadings version 1 commands. These are more or less deprecated,
  244. % but they continue to work.
  245. \newcommand{\lhead}{\@ifnextchar[{\@xlhead}{\@ylhead}}
  246. \def\@xlhead[#1]#2{\fancy@def\f@ncyelh{#1}\fancy@def\f@ncyolh{#2}}
  247. \def\@ylhead#1{\fancy@def\f@ncyelh{#1}\fancy@def\f@ncyolh{#1}}
  248. \newcommand{\chead}{\@ifnextchar[{\@xchead}{\@ychead}}
  249. \def\@xchead[#1]#2{\fancy@def\f@ncyech{#1}\fancy@def\f@ncyoch{#2}}
  250. \def\@ychead#1{\fancy@def\f@ncyech{#1}\fancy@def\f@ncyoch{#1}}
  251. \newcommand{\rhead}{\@ifnextchar[{\@xrhead}{\@yrhead}}
  252. \def\@xrhead[#1]#2{\fancy@def\f@ncyerh{#1}\fancy@def\f@ncyorh{#2}}
  253. \def\@yrhead#1{\fancy@def\f@ncyerh{#1}\fancy@def\f@ncyorh{#1}}
  254. \newcommand{\lfoot}{\@ifnextchar[{\@xlfoot}{\@ylfoot}}
  255. \def\@xlfoot[#1]#2{\fancy@def\f@ncyelf{#1}\fancy@def\f@ncyolf{#2}}
  256. \def\@ylfoot#1{\fancy@def\f@ncyelf{#1}\fancy@def\f@ncyolf{#1}}
  257. \newcommand{\cfoot}{\@ifnextchar[{\@xcfoot}{\@ycfoot}}
  258. \def\@xcfoot[#1]#2{\fancy@def\f@ncyecf{#1}\fancy@def\f@ncyocf{#2}}
  259. \def\@ycfoot#1{\fancy@def\f@ncyecf{#1}\fancy@def\f@ncyocf{#1}}
  260. \newcommand{\rfoot}{\@ifnextchar[{\@xrfoot}{\@yrfoot}}
  261. \def\@xrfoot[#1]#2{\fancy@def\f@ncyerf{#1}\fancy@def\f@ncyorf{#2}}
  262. \def\@yrfoot#1{\fancy@def\f@ncyerf{#1}\fancy@def\f@ncyorf{#1}}
  263. \newlength{\fancy@headwidth}
  264. \let\headwidth\fancy@headwidth
  265. \newlength{\f@ncyO@elh}
  266. \newlength{\f@ncyO@erh}
  267. \newlength{\f@ncyO@olh}
  268. \newlength{\f@ncyO@orh}
  269. \newlength{\f@ncyO@elf}
  270. \newlength{\f@ncyO@erf}
  271. \newlength{\f@ncyO@olf}
  272. \newlength{\f@ncyO@orf}
  273. \newcommand{\headrulewidth}{0.4pt}
  274. \newcommand{\footrulewidth}{0pt}
  275. \newcommand{\footruleskip}{.3\normalbaselineskip}
  276. % Fancyplain stuff shouldn't be used anymore (rather
  277. % \fancypagestyle{plain} should be used), but it must be present for
  278. % compatibility reasons.
  279. \newcommand{\plainheadrulewidth}{0pt}
  280. \newcommand{\plainfootrulewidth}{0pt}
  281. \newif\if@fancyplain \@fancyplainfalse
  282. \def\fancyplain#1#2{\if@fancyplain#1\else#2\fi}
  283. \headwidth=-123456789sp %magic constant
  284. % Command to reset various things in the headers:
  285. % a.o. single spacing (taken from setspace.sty)
  286. % and the catcode of ^^M (so that epsf files in the header work if a
  287. % verbatim crosses a page boundary)
  288. % It also defines a \nouppercase command that disables \uppercase and
  289. % \Makeuppercase. It can only be used in the headers and footers.
  290. \let\fnch@everypar\everypar% save real \everypar because of spanish.ldf
  291. \def\fancy@reset{\fnch@everypar{}\restorecr\endlinechar=13
  292. \def\baselinestretch{1}%
  293. \def\nouppercase##1{{\let\uppercase\relax\let\MakeUppercase\relax
  294. \expandafter\let\csname MakeUppercase \endcsname\relax##1}}%
  295. \ifx\undefined\@newbaseline% NFSS not present; 2.09 or 2e
  296. \ifx\@normalsize\undefined \normalsize % for ucthesis.cls
  297. \else \@normalsize \fi
  298. \else% NFSS (2.09) present
  299. \@newbaseline%
  300. \fi}
  301. % Initialization of the head and foot text.
  302. % The default values still contain \fancyplain for compatibility.
  303. \fancyhf{} % clear all
  304. % lefthead empty on ``plain'' pages, \rightmark on even, \leftmark on odd pages
  305. % evenhead empty on ``plain'' pages, \leftmark on even, \rightmark on odd pages
  306. \if@twoside
  307. \fancyhead[el,or]{\fancyplain{}{\sl\rightmark}}
  308. \fancyhead[er,ol]{\fancyplain{}{\sl\leftmark}}
  309. \else
  310. \fancyhead[l]{\fancyplain{}{\sl\rightmark}}
  311. \fancyhead[r]{\fancyplain{}{\sl\leftmark}}
  312. \fi
  313. \fancyfoot[c]{\rm\thepage} % page number
  314. % Use box 0 as a temp box and dimen 0 as temp dimen.
  315. % This can be done, because this code will always
  316. % be used inside another box, and therefore the changes are local.
  317. \def\@fancyvbox#1#2{\setbox0\vbox{#2}\ifdim\ht0>#1\@fancywarning
  318. {\string#1 is too small (\the#1): ^^J Make it at least \the\ht0.^^J
  319. We now make it that large for the rest of the document.^^J
  320. This may cause the page layout to be inconsistent, however\@gobble}%
  321. \dimen0=#1\global\setlength{#1}{\ht0}\ht0=\dimen0\fi
  322. \box0}
  323. % Put together a header or footer given the left, center and
  324. % right text, fillers at left and right and a rule.
  325. % The \lap commands put the text into an hbox of zero size,
  326. % so overlapping text does not generate an errormessage.
  327. % These macros have 5 parameters:
  328. % 1. LEFTSIDE BEARING % This determines at which side the header will stick
  329. % out. When \fancyhfoffset is used this calculates \headwidth, otherwise
  330. % it is \hss or \relax (after expansion).
  331. % 2. \f@ncyolh, \f@ncyelh, \f@ncyolf or \f@ncyelf. This is the left component.
  332. % 3. \f@ncyoch, \f@ncyech, \f@ncyocf or \f@ncyecf. This is the middle comp.
  333. % 4. \f@ncyorh, \f@ncyerh, \f@ncyorf or \f@ncyerf. This is the right component.
  334. % 5. RIGHTSIDE BEARING. This is always \relax or \hss (after expansion).
  335. \def\@fancyhead#1#2#3#4#5{#1\hbox to\headwidth{\fancy@reset
  336. \@fancyvbox\headheight{\hbox
  337. {\rlap{\parbox[b]{\headwidth}{\raggedright#2}}\hfill
  338. \parbox[b]{\headwidth}{\centering#3}\hfill
  339. \llap{\parbox[b]{\headwidth}{\raggedleft#4}}}\headrule}}#5}
  340. \def\@fancyfoot#1#2#3#4#5{#1\hbox to\headwidth{\fancy@reset
  341. \@fancyvbox\footskip{\footrule
  342. \hbox{\rlap{\parbox[t]{\headwidth}{\raggedright#2}}\hfill
  343. \parbox[t]{\headwidth}{\centering#3}\hfill
  344. \llap{\parbox[t]{\headwidth}{\raggedleft#4}}}}}#5}
  345. \def\headrule{{\if@fancyplain\let\headrulewidth\plainheadrulewidth\fi
  346. \hrule\@height\headrulewidth\@width\headwidth \vskip-\headrulewidth}}
  347. \def\footrule{{\if@fancyplain\let\footrulewidth\plainfootrulewidth\fi
  348. \vskip-\footruleskip\vskip-\footrulewidth
  349. \hrule\@width\headwidth\@height\footrulewidth\vskip\footruleskip}}
  350. \def\ps@fancy{%
  351. \@ifundefined{@chapapp}{\let\@chapapp\chaptername}{}%for amsbook
  352. %
  353. % Define \MakeUppercase for old LaTeXen.
  354. % Note: we used \def rather than \let, so that \let\uppercase\relax (from
  355. % the version 1 documentation) will still work.
  356. %
  357. \@ifundefined{MakeUppercase}{\def\MakeUppercase{\uppercase}}{}%
  358. \@ifundefined{chapter}{\def\sectionmark##1{\markboth
  359. {\MakeUppercase{\ifnum \c@secnumdepth>\z@
  360. \thesection\hskip 1em\relax \fi ##1}}{}}%
  361. \def\subsectionmark##1{\markright {\ifnum \c@secnumdepth >\@ne
  362. \thesubsection\hskip 1em\relax \fi ##1}}}%
  363. {\def\chaptermark##1{\markboth {\MakeUppercase{\ifnum \c@secnumdepth>\m@ne
  364. \@chapapp\ \thechapter. \ \fi ##1}}{}}%
  365. \def\sectionmark##1{\markright{\MakeUppercase{\ifnum \c@secnumdepth >\z@
  366. \thesection. \ \fi ##1}}}}%
  367. %\csname ps@headings\endcsname % use \ps@headings defaults if they exist
  368. \ps@@fancy
  369. \gdef\ps@fancy{\@fancyplainfalse\ps@@fancy}%
  370. % Initialize \headwidth if the user didn't
  371. %
  372. \ifdim\headwidth<0sp
  373. %
  374. % This catches the case that \headwidth hasn't been initialized and the
  375. % case that the user added something to \headwidth in the expectation that
  376. % it was initialized to \textwidth. We compensate this now. This loses if
  377. % the user intended to multiply it by a factor. But that case is more
  378. % likely done by saying something like \headwidth=1.2\textwidth.
  379. % The doc says you have to change \headwidth after the first call to
  380. % \pagestyle{fancy}. This code is just to catch the most common cases were
  381. % that requirement is violated.
  382. %
  383. \global\advance\headwidth123456789sp\global\advance\headwidth\textwidth
  384. \fi}
  385. \def\ps@fancyplain{\ps@fancy \let\ps@plain\ps@plain@fancy}
  386. \def\ps@plain@fancy{\@fancyplaintrue\ps@@fancy}
  387. \let\ps@@empty\ps@empty
  388. \def\ps@@fancy{%
  389. \ps@@empty % This is for amsbook/amsart, which do strange things with \topskip
  390. \def\@mkboth{\protect\markboth}%
  391. \def\@oddhead{\@fancyhead\fancy@Oolh\f@ncyolh\f@ncyoch\f@ncyorh\fancy@Oorh}%
  392. \def\@oddfoot{\@fancyfoot\fancy@Oolf\f@ncyolf\f@ncyocf\f@ncyorf\fancy@Oorf}%
  393. \def\@evenhead{\@fancyhead\fancy@Oelh\f@ncyelh\f@ncyech\f@ncyerh\fancy@Oerh}%
  394. \def\@evenfoot{\@fancyfoot\fancy@Oelf\f@ncyelf\f@ncyecf\f@ncyerf\fancy@Oerf}%
  395. }
  396. % Default definitions for compatibility mode:
  397. % These cause the header/footer to take the defined \headwidth as width
  398. % And to shift in the direction of the marginpar area
  399. \def\fancy@Oolh{\if@reversemargin\hss\else\relax\fi}
  400. \def\fancy@Oorh{\if@reversemargin\relax\else\hss\fi}
  401. \let\fancy@Oelh\fancy@Oorh
  402. \let\fancy@Oerh\fancy@Oolh
  403. \let\fancy@Oolf\fancy@Oolh
  404. \let\fancy@Oorf\fancy@Oorh
  405. \let\fancy@Oelf\fancy@Oelh
  406. \let\fancy@Oerf\fancy@Oerh
  407. % New definitions for the use of \fancyhfoffset
  408. % These calculate the \headwidth from \textwidth and the specified offsets.
  409. \def\fancy@offsolh{\headwidth=\textwidth\advance\headwidth\f@ncyO@olh
  410. \advance\headwidth\f@ncyO@orh\hskip-\f@ncyO@olh}
  411. \def\fancy@offselh{\headwidth=\textwidth\advance\headwidth\f@ncyO@elh
  412. \advance\headwidth\f@ncyO@erh\hskip-\f@ncyO@elh}
  413. \def\fancy@offsolf{\headwidth=\textwidth\advance\headwidth\f@ncyO@olf
  414. \advance\headwidth\f@ncyO@orf\hskip-\f@ncyO@olf}
  415. \def\fancy@offself{\headwidth=\textwidth\advance\headwidth\f@ncyO@elf
  416. \advance\headwidth\f@ncyO@erf\hskip-\f@ncyO@elf}
  417. \def\fancy@setoffs{%
  418. % Just in case \let\headwidth\textwidth was used
  419. \fancy@gbl\let\headwidth\fancy@headwidth
  420. \fancy@gbl\let\fancy@Oolh\fancy@offsolh
  421. \fancy@gbl\let\fancy@Oelh\fancy@offselh
  422. \fancy@gbl\let\fancy@Oorh\hss
  423. \fancy@gbl\let\fancy@Oerh\hss
  424. \fancy@gbl\let\fancy@Oolf\fancy@offsolf
  425. \fancy@gbl\let\fancy@Oelf\fancy@offself
  426. \fancy@gbl\let\fancy@Oorf\hss
  427. \fancy@gbl\let\fancy@Oerf\hss}
  428. \newif\iffootnote
  429. \let\latex@makecol\@makecol
  430. \def\@makecol{\ifvoid\footins\footnotetrue\else\footnotefalse\fi
  431. \let\topfloat\@toplist\let\botfloat\@botlist\latex@makecol}
  432. \def\iftopfloat#1#2{\ifx\topfloat\empty #2\else #1\fi}
  433. \def\ifbotfloat#1#2{\ifx\botfloat\empty #2\else #1\fi}
  434. \def\iffloatpage#1#2{\if@fcolmade #1\else #2\fi}
  435. \newcommand{\fancypagestyle}[2]{%
  436. \@namedef{ps@#1}{\let\fancy@gbl\relax#2\relax\ps@fancy}}
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...