summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/ncctools/source/nccfancyhdr.dtx
blob: 877e367184c80377f7f7a48861609bfbfd52fd00 (plain)
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
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
% \iffalse
%%
%% File: nccfancyhdr.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko
%%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{nccfancyhdr}
%<package>         [2004/12/07 v1.1 Improved Fancy Header Package (NCC)]
%
% \changes{v1.00}{2002/02/01}{This version was uploaded to CTAN}
% \changes{v1.01}{2002/02/07}{|\fancycenter| command added}
% \changes{v1.01}{2002/02/07}{Header and footer struts are moved out of par-boxes}
% \changes{v1.1}{2004/12/07}{The |\newpagestyle| command added}
% \changes{v1.1}{2004/12/07}{The |\headrule| and |\footrule| commands added}
% \changes{v1.1}{2004/12/07}{Add optional \meta{stretch} parameter in |\fancycenter|}
% \changes{v1.1}{2004/12/07}{Remove |\fancycentersep| and |\fancycenterstretch| macros}
% \changes{v1.1}{2004/12/07}{Add conditional testing of floats within |testfloats| option}
% \changes{v1.1}{2004/12/07}{Documentation was prepared}
%
%<*driver>
\let\makeindex\relax
\documentclass{ltxdoc}
\usepackage{nccboxes}
\usepackage[headings]{nccfancyhdr}
\newpagestyle{lheadings}[headings]{%
  \fancyhead[ce]{\nouppercase{\fancycenter{\thepage}{}{\slshape\leftmark}}}%
  \fancyhead[co]{\nouppercase{\fancycenter{\slshape\rightmark}{}{\thepage}}}%
}
\pagestyle{lheadings}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{0.6\marginparwidth}
\renewcommand{\headrulewidth}{0.6pt}
\makeatletter
\renewcommand{\headrule}{%
  \setlength\@tempdima{\headrulewidth}%
  \hrule\@height\@tempdima\@width\headwidth
  \vskip 2\@tempdima
  \hrule\@height\@tempdima\@width\headwidth
  \vskip -4\@tempdima
}
\makeatother
\GetFileInfo{nccfancyhdr.sty}
\begin{document}
\title{The \textsf{nccfancyhdr} package\thanks{This file
        has version number \fileversion, last
        revised \filedate.}}
\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru}
\date{\filedate}
\maketitle
\DocInput{nccfancyhdr.dtx}
\end{document}
%</driver>
% \fi
% This package is originated on the |fancyhdr| package by Piet van Oostrum.
% It provides almost the same functionality but implements it in more safe
% and simple way.
% The most important reason for re-implementation the |fancyhdr| was that
% |fancy| page style breaks conventions on page styles definition:
% avoiding global definitions in page styling commands. If this contract is
% broken, a page style cannot be used locally as a parameter of the
% |\thispagestyle| command. Other reasons for such re-implementation were
% the following: some commands in |fancyhdr| do more than it is
% necessary (e.g.\ the |fancy| page style redefines section marks),
% incorrect vertical alignment in headers leads to raising headers a bit
% (this produces a page overfull if header height is exactly the same as
% a height of text in it), some features introduced in the |fancyhdr|
% are unsafe (a special cycle |\@forc| is introduced with the |\def|
% command), and the implementation of commands is frequently too
% complicated. All these disadvantages of |fancyhdr| set off me to
% prepare a new version of |fancyhdr| packaged named as the |nccfancyhdr|.
%
% \tableofcontents
%
% \section{Using the Package}
%
% \thispagestyle{plain}
% The package supports three-part headers and footers separated
% from the text area with optional decorative lines. Using fancy headers
% and footers you can easy customize page layout.
%
% The first and the most useful benefit of fancy page styles is
% the possibility of decoration of headers and footers with a rule.
% If you want to add
% a rule to some of standard page styles (|empty|, |plain|, |myheadings|,
% and |headings|), put their names in the list of
% options of the |\usepackage| command:
% \begin{quote}
% |\usepackage|\oarg{style-list}|{nccfancyhdr}|
% \end{quote}
% For example, the command
% \begin{quote}
% |\usepackage[plain,headings]{nccfancyhdr}|
% \end{quote}
% loads the |nccfancyhdr| package and redefines the |plain| and |headings|
% styles on the base of |fancy| page style. It also sets the last style
% in the list (e.g.\ |headings| style) as a default page style.
%
% \section{Rule Control}
%
% \DescribeMacro{\headrulewidth}
% \DescribeMacro{\footrulewidth}
% The widths of decorative rules for header and footer are coded in the\linebreak
% |\headrulewidth| and |\footrulewidth| commands respectively
% (these commands were ported from the |fancyhdr| package).
% The default values for these commands are |0.4pt| (standard head rule width)
% and |0pt| (no foot rule).
% To change defaults, you should redefine corresponding commands.
% For example, to set a head rule of |0.6pt| width in this document,
% we use the following command:
% \begin{quote}
% |\renewcommand{\headrulewidth}{0.6pt}|
% \end{quote}
%
% \DescribeMacro{\headstrutheight}
% \DescribeMacro{\footstrutheight}
% A distance between rules and headers/footers is controlled with the\linebreak
% |\headstrutheight| and |\footstrutheight| commands.
% Here is a distinction with the |fancyhdr| package. The |fancyhdr| allows
% control the distance between the decoration rule and the page foot only
% in the |\footruleskip| command. Moreover, we use another technique to provide
% separation between header/footer and its rule: we insert special struts
% in headers and footers whose height and depth are calculated using the
% values of the mentioned commands. The defaults for both |\headstrutheight|
% and |\footstrutheight| are |0.3\normalbaselineskip|. You can redefine
% them in just the same manner as rule width commands above.
%
% \DescribeMacro{\headrule}
% \DescribeMacro{\footrule}
% The decorative rules in the header and footer are prepared with the\linebreak
% |\headrule| and |\footrule| commands. These commands work in vertical
% mode. They put an |\hrule| and do a negative |\vskip| to compensate
% the rule height (see the implementation section for more details).
% You can redefine these rules to produce custom decoration lines. For example,
% the double line in the header of this document is produced with the following
% code:
% \begin{quote}
% |\makeatletter|\\
% |\renewcommand{\headrule}{%|\\
% |  \setlength\@tempdima{\headrulewidth}%|\\
% |  \hrule\@height\@tempdima\@width\headwidth|\\
% |  \vskip 2\@tempdima|\\
% |  \hrule\@height\@tempdima\@width\headwidth|\\
% |  \vskip -4\@tempdima|\\
% |}|\\
% |\makeatother|
% \end{quote}
%
% \DescribeMacro{\headwidth}
% \DescribeMacro{\normalheaders}
% \DescribeMacro{\extendedheaders}
% The width of header and footer (and, of course, the widths of their rules)
% is controlled with the |\headwidth| register. It is usually equal to the
% |\textwidth| but can exceed it. In the last case, the headers and footers are
% expanded on the marginal area. To simplify control of the |\headwidth|,
% two service commands are introduced in the package. The |\normalheaders|
% command sets the |\headwidth| to the |\textwidth|. The
% |\extendedheaders| enlarges the headers and footers on the whole marginal area:
% in two-column mode, header and footer are expanded to both margins and, in
% one-column mode, header and footer are expanded to the
% outer margin, but, if reverse margin mode is on, they are expanded to
% the inner margin. In this document, the |\headwidth| is expanded to marginal
% area as follows:
% \begin{quote}
% |\addtolength{\headwidth}{\marginparsep}|\\
% |\addtolength{\headwidth}{0.6\marginparwidth}|
% \end{quote}
%
% \section{Page Style Customization}
%
% To customize a page style of your document, you can do the following:
% set the |\pagestyle{fancy}| in the preamble of the document
% and specify values of header and footer marks with the following
% commands:\vspace{-\baselineskip}
% \begin{center}\catcode`|=12
% \small
% \renewcommand\cboxstyle{\footnotesize}
% \begin{tabular}{|l|c|l|}\hline
% \hfill\cbox{Command}\hfill\mbox{} &
% \hfill\cbox{Default optional\\parameter}\hfill\mbox{} &
% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline
% \Strut/.8/
% \verb+\fancyhf+\oarg{pos-list}\marg{mark} &
% \verb+[lh,ch,rh,lf,cf,rf]+ &
% Set a mark for header/footer \\
% \verb+\fancyhead+\oarg{pos-list}\marg{mark} &
% \verb+[l,c,r]+ &
% Set a mark for header \\
% \verb+\fancyfoot+\oarg{pos-list}\marg{mark} &
% \verb+[l,c,r]+ &
% Set a mark for footer \\
% \verb+\lhead+\oarg{even-mark}\marg{odd-mark} &
% \oarg{odd-mark} &
% Set the left mark of header\\
% \verb+\chead+\oarg{even-mark}\marg{odd-mark} &
% \oarg{odd-mark} &
% Set the center mark of header\\
% \verb+\rhead+\oarg{even-mark}\marg{odd-mark} &
% \oarg{odd-mark} &
% Set the right mark of header\\
% \verb+\lfoot+\oarg{even-mark}\marg{odd-mark} &
% \oarg{odd-mark} &
% Set the left mark of footer\\
% \verb+\cfoot+\oarg{even-mark}\marg{odd-mark} &
% \oarg{odd-mark} &
% Set the center mark of footer\\
% \verb+\rfoot+\oarg{even-mark}\marg{odd-mark} &
% \oarg{odd-mark} &
% Set the right mark of footer\\\hline
% \end{tabular}
% \end{center}
%
% All these commands are ported from the |fancyhdr| package.
%
% \DescribeMacro{\fancyhf}
% The |\fancyhf| command allows specify any mark of header or footer.
% The \meta{pos-list} argument specifies marks to set.
% A~mark position selector in the \meta{pos-list} argument consists
% of up to three letters: header/footer selector (|h| or |f|),
% horizontal position selector (|l| or |c| or |r|), odd/even page
% selector (|o|~or~|e|). The odd/even page selector is optional.
% If it is omitted, the command is applied to the corresponding mark
% on both odd and even pages. For example, |\fancyhf[hco]{mark}|
% sets the center mark of a header for odd pages.
%
% \textit{Note\/}: the even page selector has a sense for two-side mode only.
% In one-side documents (e.g.\ reports), even page marks are ignored.
%
% \DescribeMacro{\fancyhead}
% \DescribeMacro{\fancyfoot}
% The |\fancyhead| and |\fancyfoot| commands allows specify any
% mark of header and footer respectively.
% A~mark position selector in the \meta{pos-list} argument consists
% of up to two letters: horizontal position selector (|l| or |c| or |r|)
% and odd/even page selector (|o|~or~|e|). The odd/even page selector
% is also optional. For example, |\fancyhead[l]{mark}|
% sets the left mark of a header for both odd and even pages.
%
% \textit{Note\/}: The command |\fancyhf{}| clears all marks of headers and footers.
% The |\fancyhead{}| and |\fancyfoot{}| commands clear all marks in headers
% and footers respectively.
%
% \DescribeMacro{\lhead}
% \DescribeMacro{\chead}
% \DescribeMacro{\rhead}
% \DescribeMacro{\lfoot}
% \DescribeMacro{\cfoot}
% \DescribeMacro{\rfoot}
% We also implement the old-style macros |\lhead|, |\chead|, |\rhead|,
% |\lfoot|, |\cfoot|, and |\rfoot|. Their meaning is clear enough.
% For example, the command |\rhead[even-mark]{odd-mark}| is equivalent
% to the following commands:
% \begin{quote}
% |\fancyhead[le]{even-mark}|\\
% |\fancyhead[lo]{odd-mark}|
% \end{quote}
% If an optional parameter of these commands is omitted, the same mark
% is set for both odd and even pages. For example, the command
% |\cfoot{mark}| is equivalent to the |\fancyfoot[c]{mark}|.
%
% \DescribeMacro{\nouppercase}
% You can use the |\nouppercase|\marg{text} command within a mark
% commands to ignore the |\uppercase| and |\MakeUppercase| commands
% in its parameter. For example, the
% |\rhead{\nouppercase{\rightmark}}| command ignores conversion the contents
% of |\rightmark| to uppercase.
%
% \section{Fancy Centering}
%
% The marks in a fancy header and footer are prepared using |\parbox|
% command. So, you can use multiline marks. In the header, they are
% aligned to the bottom line, but, in the footer, they are aligned to
% the top line. The maximum width of every mark is equal to the
% |\headwidth|. This can lead to overlapping of neighbour marks.
%
% \DescribeMacro{\fancycenter}
% If you want to prepare marks in more traditional way in a line
% not exceeding the |\headwidth|, you can use
% the following command in any mark command:
% \begin{quote}
% |\fancycenter|\oarg{distance}\oarg{stretch}\\
% |            |\marg{left-mark}\marg{center-mark}\marg{right-mark}
% \end{quote}
% This command works like
% \begin{center}
% |\hbox to\linewidth{|\marg{left-mark}|\hfil|\marg{center-mark}|\hfil|\marg{right-mark}|}|
% \end{center}
% but does this work more carefully trying to exactly center the central part of
% the text if possible. The solution for exact centering
% is applied if the width of \meta{center-mark} is less than
% \begin{quote}
% |\linewidth - 2*(|\meta{stretch}|*|\meta{distance}| +|\\
% |                max(width(|\meta{left-mark}|), width(|\meta{right-mark}|)))|.
% \end{quote}
% Otherwise the \meta{center-mark} will slightly migrate to a shorter item
% (\meta{left-mark} or \meta{right-mark}), but at least \meta{distance}
% space between all parts of line is provided.
% The default values of \meta{distance} and \meta{stretch}
% are |1em| and |3|.
%
% If the \meta{center-mark} is empty, the |\fancycenter| is equivalent to
% the following command:
% \begin{center}
% |\hbox to\linewidth {|\marg{left-mark}|\hfil |\marg{right-mark}|}|
% \end{center}
%
% \textit{Note\/}: The usage of |\fancycenter| command is not limited with the
% argument of header/footer marks only. You can use it anywhere in your document.
%
% \section{Prepare Custom Page Styles}
%
% \DescribeMacro{\newpagestyle}
% In the |nccfancyhdr| package, we recommend to set fancy marks within
% definition of a custom page style. In this case,
% you can easy select a custom style with the
% |\pagestyle| or |\thispagestyle| command. To support this, the
% |\newpagestyle| command is introduced:
% \begin{quote}
% |\newpagestyle|\marg{style-name}\oarg{base-style}\marg{definitions}
% \end{quote}
% It is allowed in the preamble only. The \meta{base-style} is a style
% the new style will be based on. If the optional parameter is omitted, the
% |fancy| style is used as the base style.
% The |fancy| style works as the |empty| style, but support decorative
% rules and extended headers/footers and allows fancy marks.
% A desired page style works as follows:
% at the first, the base style is applied; after that, the \meta{definitions}
% customize the base style.
%
% \textit{Note\/}: You can use any existing \meta{base-style} in the
% definition of a new style, but, if you apply fancy mark commands in the
% \meta{definitions} parameter, the base style should be based on the
% |fancy| style.
%
% For example, all pages of this document except the first one were prepared
% with the custom page style as follows:
% \begin{quote}
% |\usepackage[headings]{nccfancyhdr}|\\
% |\newpagestyle{lheadings}[headings]{%|\\
% |  \fancyhead[ce]{\nouppercase{%|\\
% |    \fancycenter{\thepage}{}{\slshape\leftmark}}}%|\\
% |  \fancyhead[co]{\nouppercase{%|\\
% |    \fancycenter{\slshape\rightmark}{}{\thepage}}}%|\\
% |}|\\
% |\pagestyle{lheadings}|
% \end{quote}
% As you can see from here, the fancy versions of |headings| and
% |myheadings| styles use the center mark only and prepare it
% with the help of the |\fancycenter| command.
%
% \section{How to Change a Page Style in Floatpages?}
%
% A floatpage is a page consisting of floats only. You cannot
% directly change a page style for such a page, because it is prepared
% in whole in the \LaTeX\ Output Routine.
% We recommend to change a page style for floatpages with the help of the
% |afterpage| package. Just add a command |\usepackage{afterpage}|
% in the preamble and put the command:
% \begin{quote}
% |\afterpage{\thispagestyle|\marg{special-style}|}|
% \end{quote}
% anywhere in the page going before the floatpage.
% The \meta{special-style} is a style you want to apply for
% floatpages.
%
% \DescribeMacro{\iffloatpage}
% \DescribeMacro{\iftopfloat}
% \DescribeMacro{\ifbotfloat}
% Another way for change a page style on pages with floats
% consists in using the following conditional commands within marks of
% a page style:
% \begin{quote}
% |\iffloatpage|\marg{true-clause}\marg{false-clause}\\
% |\iftopfloat|\marg{true-clause}\marg{false-clause}\\
% |\ifbotfloat|\marg{true-clause}\marg{false-clause}
% \end{quote}
% These commands were ported from the |fancyhdr| package.
% The |\iffloatpage| command executes the \meta{true-clause} if
% this is a floatpage. Otherwise, it executes the \meta{false-clause}.
% Analogously, the |\iftopfloat| and |\ifbotfloat| test the
% lists of top floats and bottom floats of the page to be nonempty.
%
% Whereas these commands are rare used, they are defined if the
% package is loaded with the |testfloats| option.
%
% \section{Package Options}
%
% In conclusion, we enumerate all package options available:
% \begin{center}\catcode`|=12
% \small\tabcolsep=10pt
% \renewcommand\cboxstyle{\footnotesize}
% \begin{tabular}{|l|l|}\hline
% \hfill\cbox{Option}\hfill\mbox{} &
% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline
% \Strut/.8/
% \texttt{empty} & redefine the \texttt{empty} page style to be fancy-based style \\
% \texttt{plain} & redefine the \texttt{plain} page style to be fancy-based style \\
% \texttt{headings} & redefine the \texttt{headings} page style to be fancy-based style \\
% \texttt{myheadings} & redefine the \texttt{myheadings} page style to be fancy-based style \\
% \texttt{testfloats} & define \verb+\iffloatpage+, \verb+\iftopfloat+,
% and \verb+\ifbotfloat+ commands\\
% \hline
% \end{tabular}
% \end{center}
% The options are executed in the order they are specified in the list of options.
% Every page
% style redefinition option sets a redefined style to be the current page style.
% Therefore, after loading of this package, the style redefined in the last order
% will be the current page style.
% \StopEventually{}
%
% \section{The Implementation}
%
% \begin{macro}{\newpagestyle}
% We start with the |\newpagestyle| command. It was introduced in
% the version~1.1 of the package. It is available in the preamble only.
%    \begin{macrocode}
%<*package>
\newcommand*{\newpagestyle}[1]{%
  \@ifnextchar[{\NCC@newpagestyle{#1}}{\NCC@newpagestyle{#1}[fancy]}%
}
\long\def\NCC@newpagestyle#1[#2]#3{%
  \@ifundefined{ps@#2}{%
    \PackageError{nccfancyhdr}
      {\string\newpagestyle: Unknown base page style `#2'}{}%
  }{}%
  \edef\@tempa{\noexpand\newcommand \expandafter\noexpand
    \csname ps@#1\endcsname}%
  \expandafter\@tempa\expandafter{\csname ps@#2\endcsname #3}%
}
\@onlypreamble\newpagestyle
\@onlypreamble\NCC@newpagestyle
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\fancyhf}
% \begin{macro}{\fancyhead}
% \begin{macro}{\fancyfoot}
% Now we define the new-style fancy marking commands. They are based
% on the |\NCC@fancyhf| command.
%    \begin{macrocode}
\newcommand*{\fancyhf}[1][lh,ch,rh,lf,cf,rf]{\NCC@fancyhf{}{#1}}
\newcommand*{\fancyhead}[1][l,c,r]{\NCC@fancyhf h{#1}}
\newcommand*{\fancyfoot}[1][l,c,r]{\NCC@fancyhf f{#1}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lhead}
% \begin{macro}{\chead}
% \begin{macro}{\rhead}
% \begin{macro}{\lfoot}
% \begin{macro}{\cfoot}
% \begin{macro}{\rfoot}
% The old-style fancy-marking commands are based on the |\NCC@fancy|
% command.
%    \begin{macrocode}
\newcommand{\lhead}{\@dblarg{\NCC@fancy{lh}}}
\newcommand{\chead}{\@dblarg{\NCC@fancy{ch}}}
\newcommand{\rhead}{\@dblarg{\NCC@fancy{rh}}}
\newcommand{\lfoot}{\@dblarg{\NCC@fancy{lf}}}
\newcommand{\cfoot}{\@dblarg{\NCC@fancy{cf}}}
\newcommand{\rfoot}{\@dblarg{\NCC@fancy{rf}}}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\NCC@fancy}
% The |\NCC@fancy|\marg{selector}\oarg{even-mark}\marg{odd-mark}
% command sets a pair of marks. A \meta{selector} consists of two
% letters: (lcr) and (hf). We need not test the \meta{selector} on
% correctness because this command is applied internally.
%    \begin{macrocode}
\def\NCC@fancy#1[#2]#3{
  \expandafter\def\csname NCC@f@e#1\endcsname{#2}%
  \expandafter\def\csname NCC@f@o#1\endcsname{#3}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@fancyhf}
% The |\NCC@fancyhf|\marg{hf}\marg{pos-list}\marg{mark} command
% parses the \meta{pos-list} by selectors and executes the
% |\NCC@fancydef| for every selector. The \meta{hf} argument
% contains the common part of all selectors added at their
% beginning.
%    \begin{macrocode}
\def\NCC@fancyhf#1#2#3{%
  \@for\@tempa:=#2\do
    {\edef\@tempa{\noexpand\NCC@fancydef{#1\@tempa}}\@tempa{#3}}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@fancydef}
% The |\NCC@fancydef|\marg{selector}\marg{mark} command analyzes
% the \meta{selector} and defines corresponding fancy mark.
% It uses the |\NCC@fancyclass| command that prevents using many letters
% of the same class in the \meta{selector}. For example, it will be an
% error if more that one `l' or `c' or `r' letter appears in the
% selector.
%    \begin{macrocode}
\def\NCC@fancydef#1#2{%
%    \end{macrocode}
% The |\NCC@hf|, |\NCC@lcr|, and |\NCC@oe| will contain a letter
% of the corresponding class found in selector. Before the cycle,
% they are set to |\relax|.
%    \begin{macrocode}
  \let\NCC@hf\relax \let\NCC@lcr\relax \let\NCC@oe\relax
  \@tfor \@nextchar:=#1\do
%    \end{macrocode}
% Prepare in |\@tempa| a next letter in uppercase.
%    \begin{macrocode}
    {\edef\@tempa{\noexpand\uppercase{\noexpand\def%
       \noexpand\@tempa{\@nextchar}}}\@tempa
%    \end{macrocode}
% Test the letter and specify corresponding class.
%    \begin{macrocode}
     \if\@tempa H\NCC@fancyclass\NCC@hf{h}{#1}\else
      \if\@tempa F\NCC@fancyclass\NCC@hf{f}{#1}\else
       \if\@tempa L\NCC@fancyclass\NCC@lcr{l}{#1}\else
        \if\@tempa C\NCC@fancyclass\NCC@lcr{c}{#1}\else
         \if\@tempa R\NCC@fancyclass\NCC@lcr{r}{#1}\else
          \if\@tempa O\NCC@fancyclass\NCC@oe{o}{#1}\else
           \if\@tempa E\NCC@fancyclass\NCC@oe{e}{#1}\else
             \NCC@fancyerror{Illegal char `\@nextchar' in argument `#1'}%
           \fi
          \fi
         \fi
        \fi
       \fi
      \fi
     \fi
    }%
%    \end{macrocode}
% After cycle, we test that the |\NCC@hf| and |\NCC@lcr| classes
% are specified. The |\NCC@oe| class is optional. So, we do not test it.
% Finally, we define appropriate mark commands.
%    \begin{macrocode}
  \ifx\NCC@hf\relax \NCC@fancyerror{No `h' or `f' specified}\else
   \ifx\NCC@lcr\relax \NCC@fancyerror{No `l' or `c' or `r' specified}\else
    \ifx\NCC@oe\relax
      \expandafter\def\csname NCC@f@o\NCC@lcr\NCC@hf\endcsname{#2}%
      \expandafter\def\csname NCC@f@e\NCC@lcr\NCC@hf\endcsname{#2}%
    \else
      \expandafter\def\csname NCC@f@\NCC@oe\NCC@lcr\NCC@hf\endcsname{#2}%
    \fi
   \fi
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@fancyclass}
% The |\NCC@fancyclass|\marg{command}\marg{letter}\marg{selector}
% command tests the\linebreak \meta{command} to be |\relax| and defines
% it with the \meta{letter} argument. If the command is already defined,
% the error message is generated.
%    \begin{macrocode}
\def\NCC@fancyclass#1#2#3{%
  \ifx#1\relax
    \def#1{#2}%
  \else
    \NCC@fancyerror{Misusing the char `\@nextchar' in argument `#3'}%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@fancyerror}
% A handler of errors in fancy mark definitions.
%    \begin{macrocode}
\def\NCC@fancyerror#1{%
  \PackageError{nccfancyhdr}%
    {Fancy mark definitions:\MessageBreak#1}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\headwidth}
% \begin{macro}{\extendedheaders}
% \begin{macro}{\normalheaders}
% Now we allocate the |\headwidth| register and define
% its control commands.
%    \begin{macrocode}
\newdimen\headwidth
\newcommand{\extendedheaders}{
  \@tempdima\marginparwidth \advance\@tempdima\marginparsep
  \@tempdimb\textwidth \advance\@tempdimb\@tempdima
  \if@twocolumn \advance\@tempdimb\@tempdima \fi
  \global\headwidth\@tempdimb
}
\newcommand{\normalheaders}{\global\headwidth\textwidth}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\headrulewidth}
% \begin{macro}{\footrulewidth}
% \begin{macro}{\headstrutheight}
% \begin{macro}{\footstrutheight}
% Now we specify parameters of decoration rules: widths and struts.
%    \begin{macrocode}
\newcommand{\headrulewidth}{.4\p@}
\newcommand{\footrulewidth}{\z@}
\newcommand{\headstrutheight}{.3\normalbaselineskip}
\newcommand{\footstrutheight}{.3\normalbaselineskip}
%    \end{macrocode}
% \textit{Note\/}: Really, the head strut height is zero but its depth is equal
% to the value of |\headstrutheight|. Moreover, the foot strut height
% is a sum of |0.55\normalbaseskip| and the value of |\footstrutheight|.
% But we prefer the universal notations for command names instead of strict one,
% because users do not interested in implementation details.
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\headrule}
% The default implementation of the |\headrule|. It works in vertical mode.
% At first it draws a rule and then it inserts a negative skip for compensation.
%    \begin{macrocode}
\newcommand{\headrule}{%
  \setlength\@tempdima{\headrulewidth}%
  \hrule\@height\@tempdima\@width\headwidth
  \vskip-\@tempdima
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\footrule}
% The |\footrule| works in reverse order: at first it inserts a negative skip
% and after that it draws a rule.
%    \begin{macrocode}
\newcommand{\footrule}{%
  \setlength\@tempdima{\footrulewidth}% Can use calc here
  \vskip -\@tempdima
  \hrule \@height\@tempdima \@width\headwidth
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@fancyreset}
% The |\NCC@fancyreset| command is used at the beginning
% of fancy headers and footers. It resets font, removes
% baseline stretch and locally defines the |\nouppercase| command.
% In comparison with the |fancyhdr| package, we do not
% call the |\restorecr| command because it is obsolete now.
% We also redefine the |\uppercase| and |\MakeUppercase|
% commands in more appropriate way than in |fancyhdr|.
%    \begin{macrocode}
\def\NCC@fancyreset{\let\baselinestretch\@empty
  \long\def\nouppercase##1{%
    \begingroup
      \long\def\uppercase####1{####1}%
      \long\def\MakeUppercase####1{####1}%
      ##1%
    \endgroup
  }%
  \reset@font
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@fancyhead}
% The |\NCC@fancyhead|\marg{left-mark}\marg{center-mark}\marg{right-mark}
% command prepares the fancy header. It differs from the implementation in
% the |fancyhdr| at the following issue: the vertical box in this command
% (|\@tempboxa|) is prepared as |\vtop| box, but in the |fancyhdr| package
% it is prepared as |\vbox| box. As a consequence, in the |fancyhdr| version,
% the base line of the vertical box goes at the rule and the header slightly
% moves up.
%    \begin{macrocode}
\def\NCC@fancyhead#1#2#3{%
  \hb@xt@\headwidth{\NCC@fancyreset
    \setbox\@tempboxa\vtop{%
      \hbox{%
%    \end{macrocode}
% Prepare the left mark:
%    \begin{macrocode}
        \rlap{\parbox[b]\headwidth{\raggedright#1}}%
%    \end{macrocode}
% Insert the strut:
%    \begin{macrocode}
        \setlength\@tempdima{\headstrutheight}%
        \vrule\@width\z@\@height\z@\@depth\@tempdima
%    \end{macrocode}
% Prepare the center mark:
%    \begin{macrocode}
        \parbox[b]\headwidth{\centering#2}%
%    \end{macrocode}
% Prepare the right mark:
%    \begin{macrocode}
        \llap{\parbox[b]\headwidth{\raggedleft#3}}%
      }%
%    \end{macrocode}
% Draw decoration rule:
%    \begin{macrocode}
      \headrule
    }%
%    \end{macrocode}
% Compare the height of |\@tempboxa| with the |\headheaght|
% and correct the last one if vertical overfull appears:
%    \begin{macrocode}
    \NCC@fancytest\headheight
%    \end{macrocode}
% Put the fancy header:
%    \begin{macrocode}
    \box\@tempboxa
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@fancyfoot}
% The |\NCC@fancyfoot|\marg{left-mark}\marg{center-mark}\marg{right-mark}
% command prepares the fancy footer. Its implementation is similar to
% the |\NCC@fancyhead|.
%    \begin{macrocode}
\def\NCC@fancyfoot#1#2#3{%
  \hb@xt@\headwidth{\NCC@fancyreset
    \setbox\@tempboxa\vbox{%
      \footrule
      \hbox{%
        \rlap{\parbox[t]\headwidth{\raggedright#1}}%
        \@tempdima .55\normalbaselineskip
        \addtolength\@tempdima{\footstrutheight}%
        \vrule\@width\z@\@height\@tempdima\@depth\z@
        \parbox[t]\headwidth{\centering#2}%
        \llap{\parbox[t]\headwidth{\raggedleft#3}}%
      }%
    }%
    \NCC@fancytest\footskip
    \box\@tempboxa
  }%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@fancytest}
% The |\NCC@fancytest|\marg{register} command compares
% a value of the \meta{register} with the height of |\@tempboxa|
% and modifies the \meta{register} value if necessary.
%    \begin{macrocode}
\def\NCC@fancytest#1{%
  \ifdim\ht\@tempboxa>#1%
    \PackageWarning{nccfancyhdr}%
      {\string#1 is too small (\the#1):\MessageBreak
       Make it at least \the\ht\@tempboxa.\MessageBreak
       We now enlarge it for the rest of the document.\MessageBreak
       This may cause the page layout to be inconsistent, however}%
    \@tempdima#1\global\setlength{#1}{\ht\@tempboxa}%
    \ht\@tempboxa\@tempdima
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NCC@ihss}
% \begin{macro}{\NCC@ohss}
% The |\NCC@ihss| and |\NCC@ohss| hooks insert the |\hss| command
% at the outer and/or inner sides of header/footer to provide the proper
% enlargement it on margins.
%    \begin{macrocode}
\def\NCC@ihss{\if@twocolumn\hss\else\if@reversemargin\hss\fi\fi}
\def\NCC@ohss{\if@twocolumn\hss\else\if@reversemargin\else\hss\fi\fi}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\fancycenter}
% |\fancycenter|\oarg{dist}\oarg{stretch}\marg{left-mark}\marg{center-mark}\marg{right-mark}
%    \begin{macrocode}
\newcommand*{\fancycenter}[1][1em]{%
  \@ifnextchar[{\NCC@fancycenter{#1}}{\NCC@fancycenter{#1}[3]}%
}
\def\NCC@fancycenter#1[#2]#3#4#5{%
%    \end{macrocode}
% At first, we execute the case when the \meta{center-mark} is empty:
%    \begin{macrocode}
  \def\@tempa{#4}\ifx\@tempa\@empty
    \hb@xt@\linewidth{\color@begingroup{#3}\hfil {#5}\color@endgroup}%
  \else
%    \end{macrocode}
% All that we need to do is to calculate skips inserted before and after
% \meta{center-mark}. We will calculate them in the |\@tempskipa|
% and |\@tempskipb|. At first:
% \begin{quote}
% |\@tempdima:=|\meta{dist};\\
% |\@tempdimb:=|\meta{dist}|*|\meta{stretch};\\
% |\@tempdimc:=|\meta{dist}|*|\meta{stretch}|-|\meta{dist};\\
% |\@tempskipa:=\@tempskipb:=\@tempdimb + 1fil - \@tempdimc|;
% \end{quote}
%    \begin{macrocode}
    \setlength\@tempdima{#1}%
    \setlength{\@tempdimb}{#2\@tempdima}%
    \@tempdimc \@tempdimb \advance\@tempdimc -\@tempdima
    \setlength\@tempskipa{\@tempdimb \@plus 1fil \@minus \@tempdimc}%
    \@tempskipb\@tempskipa
%    \end{macrocode}
% At this point, the |\@tempskipa| and |\@tempskipb| registers
% have the natural size \meta{dist}|*|\meta{stretch},
% unlimited stretchability, and the minimum size \meta{dist}.
% Now we decrease the minimum size of |\@tempskipa| to zero if
% the \meta{left-mark} is empty:
%    \begin{macrocode}
    \def\@tempa{#3}\ifx\@tempa\@empty
      \addtolength\@tempskipa{\z@ \@minus \@tempdima}%
    \fi
%    \end{macrocode}
% Do the same things with the |\@tempskipb| register if the
% \meta{right-mark} is empty:
%    \begin{macrocode}
    \def\@tempa{#5}\ifx\@tempa\@empty % empty right
      \addtolength\@tempskipb{\z@ \@minus \@tempdima}%
    \fi
%    \end{macrocode}
% Finally, we correct the left and right glues taking into
% account the difference between lengthes of \meta{left-mark}
% and \meta{right-mark}. We calculate what mark is shorter
% and increase the natural size of corresponding register
% on the difference between their lengthes.
%    \begin{macrocode}
    \settowidth{\@tempdimb}{#3}%
    \settowidth{\@tempdimc}{#5}%
    \ifdim\@tempdimb>\@tempdimc
      \advance\@tempdimb -\@tempdimc
      \addtolength\@tempskipb{\@tempdimb \@minus \@tempdimb}%
    \else
      \advance\@tempdimc -\@tempdimb
      \addtolength\@tempskipa{\@tempdimc \@minus \@tempdimc}%
    \fi
%    \end{macrocode}
% The |\@tempskipa| and |\@tempskipb| are calculated. Put the box.
%    \begin{macrocode}
    \hb@xt@\linewidth{\color@begingroup{#3}\hskip \@tempskipa
                      {#4}\hskip \@tempskipb {#5}\color@endgroup}%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% The rest of the package consists of games with styles and options.
%
% \begin{macro}{\ps@fancy}
% We start from declaring the |fancy| page style. It extends the
% |empty| page style. So, we simply call the empty style and then
% redefine |\@oddhead|, |\@evenhead|, |\@oddfoot|, and |\@evenfoot|
% to be fancy one. The |\NCC@ihss| and |\NCC@ohss| hooks provide
% proper enlargement of headers/footers on margins. The |\fancyhf{}|
% command at the end of macro clears all marks.
%    \begin{macrocode}
\def\ps@fancy{\ps@empty
  \def\@oddhead{%
    \NCC@ihss \NCC@fancyhead\NCC@f@olh\NCC@f@och\NCC@f@orh \NCC@ohss}%
  \def\@evenhead{%
    \NCC@ohss \NCC@fancyhead\NCC@f@elh\NCC@f@ech\NCC@f@erh \NCC@ihss}%
  \def\@oddfoot{%
    \NCC@ihss \NCC@fancyfoot\NCC@f@olf\NCC@f@ocf\NCC@f@orf \NCC@ohss}%
  \def\@evenfoot{%
    \NCC@ohss \NCC@fancyfoot\NCC@f@elf\NCC@f@ecf\NCC@f@erf \NCC@ihss}%
  \fancyhf{}%
}
%    \end{macrocode}
% \end{macro}
%
% Standard styles are redefined optionally.
%
% \begin{macro}{\ps@empty}
% When we redefine the |empty| style, we must take into account
% that it can be also redefined (as in |amsart| and |amsbook| classes).
% So, we save its previous meaning in the |\NCC@psempty| macro and base the
% |empty| style on the saved style.
%    \begin{macrocode}
\DeclareOption{empty}{%
  \let\NCC@psempty\ps@empty
  \def\ps@empty{\NCC@psempty
    \def\@oddhead{%
      \NCC@ihss \NCC@fancyhead\NCC@f@olh\NCC@f@och\NCC@f@orh \NCC@ohss}%
    \def\@evenhead{%
      \NCC@ohss \NCC@fancyhead\NCC@f@elh\NCC@f@ech\NCC@f@erh \NCC@ihss}%
    \def\@oddfoot{%
      \NCC@ihss \NCC@fancyfoot\NCC@f@olf\NCC@f@ocf\NCC@f@orf \NCC@ohss}%
    \def\@evenfoot{%
      \NCC@ohss \NCC@fancyfoot\NCC@f@elf\NCC@f@ecf\NCC@f@erf \NCC@ihss}%
    \fancyhf{}%
  }%
  \pagestyle{empty}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ps@plain}
% The redefinition of the |plain| style is quite simple:
%    \begin{macrocode}
\DeclareOption{plain}{%
  \def\ps@plain{\ps@fancy \let\@mkboth\@gobbletwo
    \fancyfoot[c]{\thepage}%
  }%
  \pagestyle{plain}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ps@myheadings}
% The redefinition of the |myheadings| style is conditional.
% We test the |\chapter| command on existence and redefine the
% style in a bit different ways.
%    \begin{macrocode}
\DeclareOption{myheadings}{%
  \@ifundefined{chapter}{%
    \def\ps@myheadings{\ps@fancy \let\@mkboth\@gobbletwo
      \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
      \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
      \let\sectionmark\@gobble
      \let\subsectionmark\@gobble
    }%
  }{\def\ps@myheadings{\ps@fancy \let\@mkboth\@gobbletwo
      \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
      \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
      \let\chaptermark\@gobble
      \let\sectionmark\@gobble
    }%
  }%
  \pagestyle{myheadings}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\ps@headings}
% The redefinition of the |headings| style also differs for
% book-like and article-like classes. It also differs for
% one-side and two-side modes.
%    \begin{macrocode}
\DeclareOption{headings}{%
  \@ifundefined{chapter}{%
    \if@twoside
%    \end{macrocode}
% An article in two-side mode:
%    \begin{macrocode}
      \def\ps@headings{\ps@fancy \let\@mkboth\markboth
        \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
        \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
        \def\sectionmark##1{%
          \markboth{\MakeUppercase{%
            \ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}{}}%
        \def\subsectionmark##1{%
          \markright{%
            \ifnum \c@secnumdepth >\@ne \thesubsection\quad \fi##1}}%
      }%
    \else
%    \end{macrocode}
% An article in one-side mode:
%    \begin{macrocode}
      \def\ps@headings{\ps@fancy \let\@mkboth\markboth
        \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
        \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
        \def\sectionmark##1{%
          \markright {\MakeUppercase{%
            \ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}}%
        \let\subsectionmark\@gobble % Not needed but inserted for safety
      }%
    \fi
  }{\if@twoside
%    \end{macrocode}
% A book in two-side mode:
%    \begin{macrocode}
      \def\ps@headings{\ps@fancy \let\@mkboth\markboth
        \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
        \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
        \def\chaptermark##1{%
          \markboth{\MakeUppercase{%
            \ifnum \c@secnumdepth >\m@ne \if@mainmatter
              \@chapapp\ \thechapter. \ \fi\fi##1}}{}}%
        \def\sectionmark##1{%
          \markright {\MakeUppercase{%
            \ifnum \c@secnumdepth >\z@ \thesection. \ \fi##1}}}%
      }%
    \else
%    \end{macrocode}
% A book in one-side mode:
%    \begin{macrocode}
      \def\ps@headings{\ps@fancy \let\@mkboth\markboth
        \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}%
        \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}%
        \def\chaptermark##1{%
          \markright{\MakeUppercase{%
            \ifnum \c@secnumdepth >\m@ne \if@mainmatter
              \@chapapp\ \thechapter. \ \fi\fi##1}}}%
        \let\sectionmark\@gobble % Not needed but inserted for safety
      }%
    \fi
  }%
  \pagestyle{headings}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\iffloatpage}
% \begin{macro}{\iftopfloat}
% \begin{macro}{\ifbotfloat}
% These macros are defined in the |testfloats| option.
% They were ported from the |fancyhdr| and modified a bit
% in more \LaTeX\ way. It is no warrantee that these macros
% will proper work in all cases. They must be used inside
% fancy mark commands.
%    \begin{macrocode}
\DeclareOption{testfloats}{%
  \let\NCC@fancymakecol\@makecol
  \let\NCC@fancytoplist\@empty
  \let\NCC@fancybotlist\@empty
  \def\@makecol{%
    \let\NCC@fancytoplist\@toplist
    \let\NCC@fancybotlist\@botlist
    \NCC@fancymakecol
  }%
  \newcommand\iftopfloat{%
    \ifx\NCC@fancytoplist\@empty
      \expandafter\@secondoftwo
    \else
      \expandafter\@firstoftwo
    \fi
  }%
  \newcommand\ifbotfloat{%
    \ifx\NCC@fancybotlist\@empty
      \expandafter\@secondoftwo
    \else
      \expandafter\@firstoftwo
    \fi
  }%
  \newcommand\iffloatpage{%
    \if@fcolmade
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
    \fi
  }%
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% Finally, we process the options in the order they are specified
% in the options list and set the defaults.
%    \begin{macrocode}
\ProcessOptions*
\normalheaders
\fancyhf{}
%</package>
%    \end{macrocode}
\endinput