| 1 |
% \iffalse |
| 2 |
%% |
| 3 |
%% File: nccfancyhdr.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko |
| 4 |
%% |
| 5 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 6 |
%<package>\ProvidesPackage{nccfancyhdr} |
| 7 |
%<package> [2004/12/07 v1.1 Improved Fancy Header Package (NCC)] |
| 8 |
% |
| 9 |
% \changes{v1.00}{2002/02/01}{This version was uploaded to CTAN} |
| 10 |
% \changes{v1.01}{2002/02/07}{|\fancycenter| command added} |
| 11 |
% \changes{v1.01}{2002/02/07}{Header and footer struts are moved out of par-boxes} |
| 12 |
% \changes{v1.1}{2004/12/07}{The |\newpagestyle| command added} |
| 13 |
% \changes{v1.1}{2004/12/07}{The |\headrule| and |\footrule| commands added} |
| 14 |
% \changes{v1.1}{2004/12/07}{Add optional \meta{stretch} parameter in |\fancycenter|} |
| 15 |
% \changes{v1.1}{2004/12/07}{Remove |\fancycentersep| and |\fancycenterstretch| macros} |
| 16 |
% \changes{v1.1}{2004/12/07}{Add conditional testing of floats within |testfloats| option} |
| 17 |
% \changes{v1.1}{2004/12/07}{Documentation was prepared} |
| 18 |
% |
| 19 |
%<*driver> |
| 20 |
\let\makeindex\relax |
| 21 |
\documentclass{ltxdoc} |
| 22 |
\usepackage{nccboxes} |
| 23 |
\usepackage[headings]{nccfancyhdr} |
| 24 |
\newpagestyle{lheadings}[headings]{% |
| 25 |
\fancyhead[ce]{\nouppercase{\fancycenter{\thepage}{}{\slshape\leftmark}}}% |
| 26 |
\fancyhead[co]{\nouppercase{\fancycenter{\slshape\rightmark}{}{\thepage}}}% |
| 27 |
} |
| 28 |
\pagestyle{lheadings} |
| 29 |
\addtolength{\headwidth}{\marginparsep} |
| 30 |
\addtolength{\headwidth}{0.6\marginparwidth} |
| 31 |
\renewcommand{\headrulewidth}{0.6pt} |
| 32 |
\makeatletter |
| 33 |
\renewcommand{\headrule}{% |
| 34 |
\setlength\@tempdima{\headrulewidth}% |
| 35 |
\hrule\@height\@tempdima\@width\headwidth |
| 36 |
\vskip 2\@tempdima |
| 37 |
\hrule\@height\@tempdima\@width\headwidth |
| 38 |
\vskip -4\@tempdima |
| 39 |
} |
| 40 |
\makeatother |
| 41 |
\GetFileInfo{nccfancyhdr.sty} |
| 42 |
\begin{document} |
| 43 |
\title{The \textsf{nccfancyhdr} package\thanks{This file |
| 44 |
has version number \fileversion, last |
| 45 |
revised \filedate.}} |
| 46 |
\author{Alexander I. Rozhenko\\[email protected]} |
| 47 |
\date{\filedate} |
| 48 |
\maketitle |
| 49 |
\DocInput{nccfancyhdr.dtx} |
| 50 |
\end{document} |
| 51 |
%</driver> |
| 52 |
% \fi |
| 53 |
% This package is originated on the |fancyhdr| package by Piet van Oostrum. |
| 54 |
% It provides almost the same functionality but implements it in more safe |
| 55 |
% and simple way. |
| 56 |
% The most important reason for re-implementation the |fancyhdr| was that |
| 57 |
% |fancy| page style breaks conventions on page styles definition: |
| 58 |
% avoiding global definitions in page styling commands. If this contract is |
| 59 |
% broken, a page style cannot be used locally as a parameter of the |
| 60 |
% |\thispagestyle| command. Other reasons for such re-implementation were |
| 61 |
% the following: some commands in |fancyhdr| do more than it is |
| 62 |
% necessary (e.g.\ the |fancy| page style redefines section marks), |
| 63 |
% incorrect vertical alignment in headers leads to raising headers a bit |
| 64 |
% (this produces a page overfull if header height is exactly the same as |
| 65 |
% a height of text in it), some features introduced in the |fancyhdr| |
| 66 |
% are unsafe (a special cycle |\@forc| is introduced with the |\def| |
| 67 |
% command), and the implementation of commands is frequently too |
| 68 |
% complicated. All these disadvantages of |fancyhdr| set off me to |
| 69 |
% prepare a new version of |fancyhdr| packaged named as the |nccfancyhdr|. |
| 70 |
% |
| 71 |
% \tableofcontents |
| 72 |
% |
| 73 |
% \section{Using the Package} |
| 74 |
% |
| 75 |
% \thispagestyle{plain} |
| 76 |
% The package supports three-part headers and footers separated |
| 77 |
% from the text area with optional decorative lines. Using fancy headers |
| 78 |
% and footers you can easy customize page layout. |
| 79 |
% |
| 80 |
% The first and the most useful benefit of fancy page styles is |
| 81 |
% the possibility of decoration of headers and footers with a rule. |
| 82 |
% If you want to add |
| 83 |
% a rule to some of standard page styles (|empty|, |plain|, |myheadings|, |
| 84 |
% and |headings|), put their names in the list of |
| 85 |
% options of the |\usepackage| command: |
| 86 |
% \begin{quote} |
| 87 |
% |\usepackage|\oarg{style-list}|{nccfancyhdr}| |
| 88 |
% \end{quote} |
| 89 |
% For example, the command |
| 90 |
% \begin{quote} |
| 91 |
% |\usepackage[plain,headings]{nccfancyhdr}| |
| 92 |
% \end{quote} |
| 93 |
% loads the |nccfancyhdr| package and redefines the |plain| and |headings| |
| 94 |
% styles on the base of |fancy| page style. It also sets the last style |
| 95 |
% in the list (e.g.\ |headings| style) as a default page style. |
| 96 |
% |
| 97 |
% \section{Rule Control} |
| 98 |
% |
| 99 |
% \DescribeMacro{\headrulewidth} |
| 100 |
% \DescribeMacro{\footrulewidth} |
| 101 |
% The widths of decorative rules for header and footer are coded in the\linebreak |
| 102 |
% |\headrulewidth| and |\footrulewidth| commands respectively |
| 103 |
% (these commands were ported from the |fancyhdr| package). |
| 104 |
% The default values for these commands are |0.4pt| (standard head rule width) |
| 105 |
% and |0pt| (no foot rule). |
| 106 |
% To change defaults, you should redefine corresponding commands. |
| 107 |
% For example, to set a head rule of |0.6pt| width in this document, |
| 108 |
% we use the following command: |
| 109 |
% \begin{quote} |
| 110 |
% |\renewcommand{\headrulewidth}{0.6pt}| |
| 111 |
% \end{quote} |
| 112 |
% |
| 113 |
% \DescribeMacro{\headstrutheight} |
| 114 |
% \DescribeMacro{\footstrutheight} |
| 115 |
% A distance between rules and headers/footers is controlled with the\linebreak |
| 116 |
% |\headstrutheight| and |\footstrutheight| commands. |
| 117 |
% Here is a distinction with the |fancyhdr| package. The |fancyhdr| allows |
| 118 |
% control the distance between the decoration rule and the page foot only |
| 119 |
% in the |\footruleskip| command. Moreover, we use another technique to provide |
| 120 |
% separation between header/footer and its rule: we insert special struts |
| 121 |
% in headers and footers whose height and depth are calculated using the |
| 122 |
% values of the mentioned commands. The defaults for both |\headstrutheight| |
| 123 |
% and |\footstrutheight| are |0.3\normalbaselineskip|. You can redefine |
| 124 |
% them in just the same manner as rule width commands above. |
| 125 |
% |
| 126 |
% \DescribeMacro{\headrule} |
| 127 |
% \DescribeMacro{\footrule} |
| 128 |
% The decorative rules in the header and footer are prepared with the\linebreak |
| 129 |
% |\headrule| and |\footrule| commands. These commands work in vertical |
| 130 |
% mode. They put an |\hrule| and do a negative |\vskip| to compensate |
| 131 |
% the rule height (see the implementation section for more details). |
| 132 |
% You can redefine these rules to produce custom decoration lines. For example, |
| 133 |
% the double line in the header of this document is produced with the following |
| 134 |
% code: |
| 135 |
% \begin{quote} |
| 136 |
% |\makeatletter|\\ |
| 137 |
% |\renewcommand{\headrule}{%|\\ |
| 138 |
% | \setlength\@tempdima{\headrulewidth}%|\\ |
| 139 |
% | \hrule\@height\@tempdima\@width\headwidth|\\ |
| 140 |
% | \vskip 2\@tempdima|\\ |
| 141 |
% | \hrule\@height\@tempdima\@width\headwidth|\\ |
| 142 |
% | \vskip -4\@tempdima|\\ |
| 143 |
% |}|\\ |
| 144 |
% |\makeatother| |
| 145 |
% \end{quote} |
| 146 |
% |
| 147 |
% \DescribeMacro{\headwidth} |
| 148 |
% \DescribeMacro{\normalheaders} |
| 149 |
% \DescribeMacro{\extendedheaders} |
| 150 |
% The width of header and footer (and, of course, the widths of their rules) |
| 151 |
% is controlled with the |\headwidth| register. It is usually equal to the |
| 152 |
% |\textwidth| but can exceed it. In the last case, the headers and footers are |
| 153 |
% expanded on the marginal area. To simplify control of the |\headwidth|, |
| 154 |
% two service commands are introduced in the package. The |\normalheaders| |
| 155 |
% command sets the |\headwidth| to the |\textwidth|. The |
| 156 |
% |\extendedheaders| enlarges the headers and footers on the whole marginal area: |
| 157 |
% in two-column mode, header and footer are expanded to both margins and, in |
| 158 |
% one-column mode, header and footer are expanded to the |
| 159 |
% outer margin, but, if reverse margin mode is on, they are expanded to |
| 160 |
% the inner margin. In this document, the |\headwidth| is expanded to marginal |
| 161 |
% area as follows: |
| 162 |
% \begin{quote} |
| 163 |
% |\addtolength{\headwidth}{\marginparsep}|\\ |
| 164 |
% |\addtolength{\headwidth}{0.6\marginparwidth}| |
| 165 |
% \end{quote} |
| 166 |
% |
| 167 |
% \section{Page Style Customization} |
| 168 |
% |
| 169 |
% To customize a page style of your document, you can do the following: |
| 170 |
% set the |\pagestyle{fancy}| in the preamble of the document |
| 171 |
% and specify values of header and footer marks with the following |
| 172 |
% commands:\vspace{-\baselineskip} |
| 173 |
% \begin{center}\catcode`|=12 |
| 174 |
% \small |
| 175 |
% \renewcommand\cboxstyle{\footnotesize} |
| 176 |
% \begin{tabular}{|l|c|l|}\hline |
| 177 |
% \hfill\cbox{Command}\hfill\mbox{} & |
| 178 |
% \hfill\cbox{Default optional\\parameter}\hfill\mbox{} & |
| 179 |
% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline |
| 180 |
% \Strut/.8/ |
| 181 |
% \verb+\fancyhf+\oarg{pos-list}\marg{mark} & |
| 182 |
% \verb+[lh,ch,rh,lf,cf,rf]+ & |
| 183 |
% Set a mark for header/footer \\ |
| 184 |
% \verb+\fancyhead+\oarg{pos-list}\marg{mark} & |
| 185 |
% \verb+[l,c,r]+ & |
| 186 |
% Set a mark for header \\ |
| 187 |
% \verb+\fancyfoot+\oarg{pos-list}\marg{mark} & |
| 188 |
% \verb+[l,c,r]+ & |
| 189 |
% Set a mark for footer \\ |
| 190 |
% \verb+\lhead+\oarg{even-mark}\marg{odd-mark} & |
| 191 |
% \oarg{odd-mark} & |
| 192 |
% Set the left mark of header\\ |
| 193 |
% \verb+\chead+\oarg{even-mark}\marg{odd-mark} & |
| 194 |
% \oarg{odd-mark} & |
| 195 |
% Set the center mark of header\\ |
| 196 |
% \verb+\rhead+\oarg{even-mark}\marg{odd-mark} & |
| 197 |
% \oarg{odd-mark} & |
| 198 |
% Set the right mark of header\\ |
| 199 |
% \verb+\lfoot+\oarg{even-mark}\marg{odd-mark} & |
| 200 |
% \oarg{odd-mark} & |
| 201 |
% Set the left mark of footer\\ |
| 202 |
% \verb+\cfoot+\oarg{even-mark}\marg{odd-mark} & |
| 203 |
% \oarg{odd-mark} & |
| 204 |
% Set the center mark of footer\\ |
| 205 |
% \verb+\rfoot+\oarg{even-mark}\marg{odd-mark} & |
| 206 |
% \oarg{odd-mark} & |
| 207 |
% Set the right mark of footer\\\hline |
| 208 |
% \end{tabular} |
| 209 |
% \end{center} |
| 210 |
% |
| 211 |
% All these commands are ported from the |fancyhdr| package. |
| 212 |
% |
| 213 |
% \DescribeMacro{\fancyhf} |
| 214 |
% The |\fancyhf| command allows specify any mark of header or footer. |
| 215 |
% The \meta{pos-list} argument specifies marks to set. |
| 216 |
% A~mark position selector in the \meta{pos-list} argument consists |
| 217 |
% of up to three letters: header/footer selector (|h| or |f|), |
| 218 |
% horizontal position selector (|l| or |c| or |r|), odd/even page |
| 219 |
% selector (|o|~or~|e|). The odd/even page selector is optional. |
| 220 |
% If it is omitted, the command is applied to the corresponding mark |
| 221 |
% on both odd and even pages. For example, |\fancyhf[hco]{mark}| |
| 222 |
% sets the center mark of a header for odd pages. |
| 223 |
% |
| 224 |
% \textit{Note\/}: the even page selector has a sense for two-side mode only. |
| 225 |
% In one-side documents (e.g.\ reports), even page marks are ignored. |
| 226 |
% |
| 227 |
% \DescribeMacro{\fancyhead} |
| 228 |
% \DescribeMacro{\fancyfoot} |
| 229 |
% The |\fancyhead| and |\fancyfoot| commands allows specify any |
| 230 |
% mark of header and footer respectively. |
| 231 |
% A~mark position selector in the \meta{pos-list} argument consists |
| 232 |
% of up to two letters: horizontal position selector (|l| or |c| or |r|) |
| 233 |
% and odd/even page selector (|o|~or~|e|). The odd/even page selector |
| 234 |
% is also optional. For example, |\fancyhead[l]{mark}| |
| 235 |
% sets the left mark of a header for both odd and even pages. |
| 236 |
% |
| 237 |
% \textit{Note\/}: The command |\fancyhf{}| clears all marks of headers and footers. |
| 238 |
% The |\fancyhead{}| and |\fancyfoot{}| commands clear all marks in headers |
| 239 |
% and footers respectively. |
| 240 |
% |
| 241 |
% \DescribeMacro{\lhead} |
| 242 |
% \DescribeMacro{\chead} |
| 243 |
% \DescribeMacro{\rhead} |
| 244 |
% \DescribeMacro{\lfoot} |
| 245 |
% \DescribeMacro{\cfoot} |
| 246 |
% \DescribeMacro{\rfoot} |
| 247 |
% We also implement the old-style macros |\lhead|, |\chead|, |\rhead|, |
| 248 |
% |\lfoot|, |\cfoot|, and |\rfoot|. Their meaning is clear enough. |
| 249 |
% For example, the command |\rhead[even-mark]{odd-mark}| is equivalent |
| 250 |
% to the following commands: |
| 251 |
% \begin{quote} |
| 252 |
% |\fancyhead[le]{even-mark}|\\ |
| 253 |
% |\fancyhead[lo]{odd-mark}| |
| 254 |
% \end{quote} |
| 255 |
% If an optional parameter of these commands is omitted, the same mark |
| 256 |
% is set for both odd and even pages. For example, the command |
| 257 |
% |\cfoot{mark}| is equivalent to the |\fancyfoot[c]{mark}|. |
| 258 |
% |
| 259 |
% \DescribeMacro{\nouppercase} |
| 260 |
% You can use the |\nouppercase|\marg{text} command within a mark |
| 261 |
% commands to ignore the |\uppercase| and |\MakeUppercase| commands |
| 262 |
% in its parameter. For example, the |
| 263 |
% |\rhead{\nouppercase{\rightmark}}| command ignores conversion the contents |
| 264 |
% of |\rightmark| to uppercase. |
| 265 |
% |
| 266 |
% \section{Fancy Centering} |
| 267 |
% |
| 268 |
% The marks in a fancy header and footer are prepared using |\parbox| |
| 269 |
% command. So, you can use multiline marks. In the header, they are |
| 270 |
% aligned to the bottom line, but, in the footer, they are aligned to |
| 271 |
% the top line. The maximum width of every mark is equal to the |
| 272 |
% |\headwidth|. This can lead to overlapping of neighbour marks. |
| 273 |
% |
| 274 |
% \DescribeMacro{\fancycenter} |
| 275 |
% If you want to prepare marks in more traditional way in a line |
| 276 |
% not exceeding the |\headwidth|, you can use |
| 277 |
% the following command in any mark command: |
| 278 |
% \begin{quote} |
| 279 |
% |\fancycenter|\oarg{distance}\oarg{stretch}\\ |
| 280 |
% | |\marg{left-mark}\marg{center-mark}\marg{right-mark} |
| 281 |
% \end{quote} |
| 282 |
% This command works like |
| 283 |
% \begin{center} |
| 284 |
% |\hbox to\linewidth{|\marg{left-mark}|\hfil|\marg{center-mark}|\hfil|\marg{right-mark}|}| |
| 285 |
% \end{center} |
| 286 |
% but does this work more carefully trying to exactly center the central part of |
| 287 |
% the text if possible. The solution for exact centering |
| 288 |
% is applied if the width of \meta{center-mark} is less than |
| 289 |
% \begin{quote} |
| 290 |
% |\linewidth - 2*(|\meta{stretch}|*|\meta{distance}| +|\\ |
| 291 |
% | max(width(|\meta{left-mark}|), width(|\meta{right-mark}|)))|. |
| 292 |
% \end{quote} |
| 293 |
% Otherwise the \meta{center-mark} will slightly migrate to a shorter item |
| 294 |
% (\meta{left-mark} or \meta{right-mark}), but at least \meta{distance} |
| 295 |
% space between all parts of line is provided. |
| 296 |
% The default values of \meta{distance} and \meta{stretch} |
| 297 |
% are |1em| and |3|. |
| 298 |
% |
| 299 |
% If the \meta{center-mark} is empty, the |\fancycenter| is equivalent to |
| 300 |
% the following command: |
| 301 |
% \begin{center} |
| 302 |
% |\hbox to\linewidth {|\marg{left-mark}|\hfil |\marg{right-mark}|}| |
| 303 |
% \end{center} |
| 304 |
% |
| 305 |
% \textit{Note\/}: The usage of |\fancycenter| command is not limited with the |
| 306 |
% argument of header/footer marks only. You can use it anywhere in your document. |
| 307 |
% |
| 308 |
% \section{Prepare Custom Page Styles} |
| 309 |
% |
| 310 |
% \DescribeMacro{\newpagestyle} |
| 311 |
% In the |nccfancyhdr| package, we recommend to set fancy marks within |
| 312 |
% definition of a custom page style. In this case, |
| 313 |
% you can easy select a custom style with the |
| 314 |
% |\pagestyle| or |\thispagestyle| command. To support this, the |
| 315 |
% |\newpagestyle| command is introduced: |
| 316 |
% \begin{quote} |
| 317 |
% |\newpagestyle|\marg{style-name}\oarg{base-style}\marg{definitions} |
| 318 |
% \end{quote} |
| 319 |
% It is allowed in the preamble only. The \meta{base-style} is a style |
| 320 |
% the new style will be based on. If the optional parameter is omitted, the |
| 321 |
% |fancy| style is used as the base style. |
| 322 |
% The |fancy| style works as the |empty| style, but support decorative |
| 323 |
% rules and extended headers/footers and allows fancy marks. |
| 324 |
% A desired page style works as follows: |
| 325 |
% at the first, the base style is applied; after that, the \meta{definitions} |
| 326 |
% customize the base style. |
| 327 |
% |
| 328 |
% \textit{Note\/}: You can use any existing \meta{base-style} in the |
| 329 |
% definition of a new style, but, if you apply fancy mark commands in the |
| 330 |
% \meta{definitions} parameter, the base style should be based on the |
| 331 |
% |fancy| style. |
| 332 |
% |
| 333 |
% For example, all pages of this document except the first one were prepared |
| 334 |
% with the custom page style as follows: |
| 335 |
% \begin{quote} |
| 336 |
% |\usepackage[headings]{nccfancyhdr}|\\ |
| 337 |
% |\newpagestyle{lheadings}[headings]{%|\\ |
| 338 |
% | \fancyhead[ce]{\nouppercase{%|\\ |
| 339 |
% | \fancycenter{\thepage}{}{\slshape\leftmark}}}%|\\ |
| 340 |
% | \fancyhead[co]{\nouppercase{%|\\ |
| 341 |
% | \fancycenter{\slshape\rightmark}{}{\thepage}}}%|\\ |
| 342 |
% |}|\\ |
| 343 |
% |\pagestyle{lheadings}| |
| 344 |
% \end{quote} |
| 345 |
% As you can see from here, the fancy versions of |headings| and |
| 346 |
% |myheadings| styles use the center mark only and prepare it |
| 347 |
% with the help of the |\fancycenter| command. |
| 348 |
% |
| 349 |
% \section{How to Change a Page Style in Floatpages?} |
| 350 |
% |
| 351 |
% A floatpage is a page consisting of floats only. You cannot |
| 352 |
% directly change a page style for such a page, because it is prepared |
| 353 |
% in whole in the \LaTeX\ Output Routine. |
| 354 |
% We recommend to change a page style for floatpages with the help of the |
| 355 |
% |afterpage| package. Just add a command |\usepackage{afterpage}| |
| 356 |
% in the preamble and put the command: |
| 357 |
% \begin{quote} |
| 358 |
% |\afterpage{\thispagestyle|\marg{special-style}|}| |
| 359 |
% \end{quote} |
| 360 |
% anywhere in the page going before the floatpage. |
| 361 |
% The \meta{special-style} is a style you want to apply for |
| 362 |
% floatpages. |
| 363 |
% |
| 364 |
% \DescribeMacro{\iffloatpage} |
| 365 |
% \DescribeMacro{\iftopfloat} |
| 366 |
% \DescribeMacro{\ifbotfloat} |
| 367 |
% Another way for change a page style on pages with floats |
| 368 |
% consists in using the following conditional commands within marks of |
| 369 |
% a page style: |
| 370 |
% \begin{quote} |
| 371 |
% |\iffloatpage|\marg{true-clause}\marg{false-clause}\\ |
| 372 |
% |\iftopfloat|\marg{true-clause}\marg{false-clause}\\ |
| 373 |
% |\ifbotfloat|\marg{true-clause}\marg{false-clause} |
| 374 |
% \end{quote} |
| 375 |
% These commands were ported from the |fancyhdr| package. |
| 376 |
% The |\iffloatpage| command executes the \meta{true-clause} if |
| 377 |
% this is a floatpage. Otherwise, it executes the \meta{false-clause}. |
| 378 |
% Analogously, the |\iftopfloat| and |\ifbotfloat| test the |
| 379 |
% lists of top floats and bottom floats of the page to be nonempty. |
| 380 |
% |
| 381 |
% Whereas these commands are rare used, they are defined if the |
| 382 |
% package is loaded with the |testfloats| option. |
| 383 |
% |
| 384 |
% \section{Package Options} |
| 385 |
% |
| 386 |
% In conclusion, we enumerate all package options available: |
| 387 |
% \begin{center}\catcode`|=12 |
| 388 |
% \small\tabcolsep=10pt |
| 389 |
% \renewcommand\cboxstyle{\footnotesize} |
| 390 |
% \begin{tabular}{|l|l|}\hline |
| 391 |
% \hfill\cbox{Option}\hfill\mbox{} & |
| 392 |
% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline |
| 393 |
% \Strut/.8/ |
| 394 |
% \texttt{empty} & redefine the \texttt{empty} page style to be fancy-based style \\ |
| 395 |
% \texttt{plain} & redefine the \texttt{plain} page style to be fancy-based style \\ |
| 396 |
% \texttt{headings} & redefine the \texttt{headings} page style to be fancy-based style \\ |
| 397 |
% \texttt{myheadings} & redefine the \texttt{myheadings} page style to be fancy-based style \\ |
| 398 |
% \texttt{testfloats} & define \verb+\iffloatpage+, \verb+\iftopfloat+, |
| 399 |
% and \verb+\ifbotfloat+ commands\\ |
| 400 |
% \hline |
| 401 |
% \end{tabular} |
| 402 |
% \end{center} |
| 403 |
% The options are executed in the order they are specified in the list of options. |
| 404 |
% Every page |
| 405 |
% style redefinition option sets a redefined style to be the current page style. |
| 406 |
% Therefore, after loading of this package, the style redefined in the last order |
| 407 |
% will be the current page style. |
| 408 |
% \StopEventually{} |
| 409 |
% |
| 410 |
% \section{The Implementation} |
| 411 |
% |
| 412 |
% \begin{macro}{\newpagestyle} |
| 413 |
% We start with the |\newpagestyle| command. It was introduced in |
| 414 |
% the version~1.1 of the package. It is available in the preamble only. |
| 415 |
% \begin{macrocode} |
| 416 |
%<*package> |
| 417 |
\newcommand*{\newpagestyle}[1]{% |
| 418 |
\@ifnextchar[{\NCC@newpagestyle{#1}}{\NCC@newpagestyle{#1}[fancy]}% |
| 419 |
} |
| 420 |
\long\def\NCC@newpagestyle#1[#2]#3{% |
| 421 |
\@ifundefined{ps@#2}{% |
| 422 |
\PackageError{nccfancyhdr} |
| 423 |
{\string\newpagestyle: Unknown base page style `#2'}{}% |
| 424 |
}{}% |
| 425 |
\edef\@tempa{\noexpand\newcommand \expandafter\noexpand |
| 426 |
\csname ps@#1\endcsname}% |
| 427 |
\expandafter\@tempa\expandafter{\csname ps@#2\endcsname #3}% |
| 428 |
} |
| 429 |
\@onlypreamble\newpagestyle |
| 430 |
\@onlypreamble\NCC@newpagestyle |
| 431 |
% \end{macrocode} |
| 432 |
% \end{macro} |
| 433 |
% |
| 434 |
% \begin{macro}{\fancyhf} |
| 435 |
% \begin{macro}{\fancyhead} |
| 436 |
% \begin{macro}{\fancyfoot} |
| 437 |
% Now we define the new-style fancy marking commands. They are based |
| 438 |
% on the |\NCC@fancyhf| command. |
| 439 |
% \begin{macrocode} |
| 440 |
\newcommand*{\fancyhf}[1][lh,ch,rh,lf,cf,rf]{\NCC@fancyhf{}{#1}} |
| 441 |
\newcommand*{\fancyhead}[1][l,c,r]{\NCC@fancyhf h{#1}} |
| 442 |
\newcommand*{\fancyfoot}[1][l,c,r]{\NCC@fancyhf f{#1}} |
| 443 |
% \end{macrocode} |
| 444 |
% \end{macro} |
| 445 |
% \end{macro} |
| 446 |
% \end{macro} |
| 447 |
% |
| 448 |
% \begin{macro}{\lhead} |
| 449 |
% \begin{macro}{\chead} |
| 450 |
% \begin{macro}{\rhead} |
| 451 |
% \begin{macro}{\lfoot} |
| 452 |
% \begin{macro}{\cfoot} |
| 453 |
% \begin{macro}{\rfoot} |
| 454 |
% The old-style fancy-marking commands are based on the |\NCC@fancy| |
| 455 |
% command. |
| 456 |
% \begin{macrocode} |
| 457 |
\newcommand{\lhead}{\@dblarg{\NCC@fancy{lh}}} |
| 458 |
\newcommand{\chead}{\@dblarg{\NCC@fancy{ch}}} |
| 459 |
\newcommand{\rhead}{\@dblarg{\NCC@fancy{rh}}} |
| 460 |
\newcommand{\lfoot}{\@dblarg{\NCC@fancy{lf}}} |
| 461 |
\newcommand{\cfoot}{\@dblarg{\NCC@fancy{cf}}} |
| 462 |
\newcommand{\rfoot}{\@dblarg{\NCC@fancy{rf}}} |
| 463 |
% \end{macrocode} |
| 464 |
% \end{macro} |
| 465 |
% \end{macro} |
| 466 |
% \end{macro} |
| 467 |
% \end{macro} |
| 468 |
% \end{macro} |
| 469 |
% \end{macro} |
| 470 |
% |
| 471 |
% \begin{macro}{\NCC@fancy} |
| 472 |
% The |\NCC@fancy|\marg{selector}\oarg{even-mark}\marg{odd-mark} |
| 473 |
% command sets a pair of marks. A \meta{selector} consists of two |
| 474 |
% letters: (lcr) and (hf). We need not test the \meta{selector} on |
| 475 |
% correctness because this command is applied internally. |
| 476 |
% \begin{macrocode} |
| 477 |
\def\NCC@fancy#1[#2]#3{ |
| 478 |
\expandafter\def\csname NCC@f@e#1\endcsname{#2}% |
| 479 |
\expandafter\def\csname NCC@f@o#1\endcsname{#3}% |
| 480 |
} |
| 481 |
% \end{macrocode} |
| 482 |
% \end{macro} |
| 483 |
% |
| 484 |
% \begin{macro}{\NCC@fancyhf} |
| 485 |
% The |\NCC@fancyhf|\marg{hf}\marg{pos-list}\marg{mark} command |
| 486 |
% parses the \meta{pos-list} by selectors and executes the |
| 487 |
% |\NCC@fancydef| for every selector. The \meta{hf} argument |
| 488 |
% contains the common part of all selectors added at their |
| 489 |
% beginning. |
| 490 |
% \begin{macrocode} |
| 491 |
\def\NCC@fancyhf#1#2#3{% |
| 492 |
\@for\@tempa:=#2\do |
| 493 |
{\edef\@tempa{\noexpand\NCC@fancydef{#1\@tempa}}\@tempa{#3}}% |
| 494 |
} |
| 495 |
% \end{macrocode} |
| 496 |
% \end{macro} |
| 497 |
% |
| 498 |
% \begin{macro}{\NCC@fancydef} |
| 499 |
% The |\NCC@fancydef|\marg{selector}\marg{mark} command analyzes |
| 500 |
% the \meta{selector} and defines corresponding fancy mark. |
| 501 |
% It uses the |\NCC@fancyclass| command that prevents using many letters |
| 502 |
% of the same class in the \meta{selector}. For example, it will be an |
| 503 |
% error if more that one `l' or `c' or `r' letter appears in the |
| 504 |
% selector. |
| 505 |
% \begin{macrocode} |
| 506 |
\def\NCC@fancydef#1#2{% |
| 507 |
% \end{macrocode} |
| 508 |
% The |\NCC@hf|, |\NCC@lcr|, and |\NCC@oe| will contain a letter |
| 509 |
% of the corresponding class found in selector. Before the cycle, |
| 510 |
% they are set to |\relax|. |
| 511 |
% \begin{macrocode} |
| 512 |
\let\NCC@hf\relax \let\NCC@lcr\relax \let\NCC@oe\relax |
| 513 |
\@tfor \@nextchar:=#1\do |
| 514 |
% \end{macrocode} |
| 515 |
% Prepare in |\@tempa| a next letter in uppercase. |
| 516 |
% \begin{macrocode} |
| 517 |
{\edef\@tempa{\noexpand\uppercase{\noexpand\def% |
| 518 |
\noexpand\@tempa{\@nextchar}}}\@tempa |
| 519 |
% \end{macrocode} |
| 520 |
% Test the letter and specify corresponding class. |
| 521 |
% \begin{macrocode} |
| 522 |
\if\@tempa H\NCC@fancyclass\NCC@hf{h}{#1}\else |
| 523 |
\if\@tempa F\NCC@fancyclass\NCC@hf{f}{#1}\else |
| 524 |
\if\@tempa L\NCC@fancyclass\NCC@lcr{l}{#1}\else |
| 525 |
\if\@tempa C\NCC@fancyclass\NCC@lcr{c}{#1}\else |
| 526 |
\if\@tempa R\NCC@fancyclass\NCC@lcr{r}{#1}\else |
| 527 |
\if\@tempa O\NCC@fancyclass\NCC@oe{o}{#1}\else |
| 528 |
\if\@tempa E\NCC@fancyclass\NCC@oe{e}{#1}\else |
| 529 |
\NCC@fancyerror{Illegal char `\@nextchar' in argument `#1'}% |
| 530 |
\fi |
| 531 |
\fi |
| 532 |
\fi |
| 533 |
\fi |
| 534 |
\fi |
| 535 |
\fi |
| 536 |
\fi |
| 537 |
}% |
| 538 |
% \end{macrocode} |
| 539 |
% After cycle, we test that the |\NCC@hf| and |\NCC@lcr| classes |
| 540 |
% are specified. The |\NCC@oe| class is optional. So, we do not test it. |
| 541 |
% Finally, we define appropriate mark commands. |
| 542 |
% \begin{macrocode} |
| 543 |
\ifx\NCC@hf\relax \NCC@fancyerror{No `h' or `f' specified}\else |
| 544 |
\ifx\NCC@lcr\relax \NCC@fancyerror{No `l' or `c' or `r' specified}\else |
| 545 |
\ifx\NCC@oe\relax |
| 546 |
\expandafter\def\csname NCC@f@o\NCC@lcr\NCC@hf\endcsname{#2}% |
| 547 |
\expandafter\def\csname NCC@f@e\NCC@lcr\NCC@hf\endcsname{#2}% |
| 548 |
\else |
| 549 |
\expandafter\def\csname NCC@f@\NCC@oe\NCC@lcr\NCC@hf\endcsname{#2}% |
| 550 |
\fi |
| 551 |
\fi |
| 552 |
\fi |
| 553 |
} |
| 554 |
% \end{macrocode} |
| 555 |
% \end{macro} |
| 556 |
% |
| 557 |
% \begin{macro}{\NCC@fancyclass} |
| 558 |
% The |\NCC@fancyclass|\marg{command}\marg{letter}\marg{selector} |
| 559 |
% command tests the\linebreak \meta{command} to be |\relax| and defines |
| 560 |
% it with the \meta{letter} argument. If the command is already defined, |
| 561 |
% the error message is generated. |
| 562 |
% \begin{macrocode} |
| 563 |
\def\NCC@fancyclass#1#2#3{% |
| 564 |
\ifx#1\relax |
| 565 |
\def#1{#2}% |
| 566 |
\else |
| 567 |
\NCC@fancyerror{Misusing the char `\@nextchar' in argument `#3'}% |
| 568 |
\fi |
| 569 |
} |
| 570 |
% \end{macrocode} |
| 571 |
% \end{macro} |
| 572 |
% |
| 573 |
% \begin{macro}{\NCC@fancyerror} |
| 574 |
% A handler of errors in fancy mark definitions. |
| 575 |
% \begin{macrocode} |
| 576 |
\def\NCC@fancyerror#1{% |
| 577 |
\PackageError{nccfancyhdr}% |
| 578 |
{Fancy mark definitions:\MessageBreak#1}% |
| 579 |
} |
| 580 |
% \end{macrocode} |
| 581 |
% \end{macro} |
| 582 |
% |
| 583 |
% \begin{macro}{\headwidth} |
| 584 |
% \begin{macro}{\extendedheaders} |
| 585 |
% \begin{macro}{\normalheaders} |
| 586 |
% Now we allocate the |\headwidth| register and define |
| 587 |
% its control commands. |
| 588 |
% \begin{macrocode} |
| 589 |
\newdimen\headwidth |
| 590 |
\newcommand{\extendedheaders}{ |
| 591 |
\@tempdima\marginparwidth \advance\@tempdima\marginparsep |
| 592 |
\@tempdimb\textwidth \advance\@tempdimb\@tempdima |
| 593 |
\if@twocolumn \advance\@tempdimb\@tempdima \fi |
| 594 |
\global\headwidth\@tempdimb |
| 595 |
} |
| 596 |
\newcommand{\normalheaders}{\global\headwidth\textwidth} |
| 597 |
% \end{macrocode} |
| 598 |
% \end{macro} |
| 599 |
% \end{macro} |
| 600 |
% \end{macro} |
| 601 |
% |
| 602 |
% \begin{macro}{\headrulewidth} |
| 603 |
% \begin{macro}{\footrulewidth} |
| 604 |
% \begin{macro}{\headstrutheight} |
| 605 |
% \begin{macro}{\footstrutheight} |
| 606 |
% Now we specify parameters of decoration rules: widths and struts. |
| 607 |
% \begin{macrocode} |
| 608 |
\newcommand{\headrulewidth}{.4\p@} |
| 609 |
\newcommand{\footrulewidth}{\z@} |
| 610 |
\newcommand{\headstrutheight}{.3\normalbaselineskip} |
| 611 |
\newcommand{\footstrutheight}{.3\normalbaselineskip} |
| 612 |
% \end{macrocode} |
| 613 |
% \textit{Note\/}: Really, the head strut height is zero but its depth is equal |
| 614 |
% to the value of |\headstrutheight|. Moreover, the foot strut height |
| 615 |
% is a sum of |0.55\normalbaseskip| and the value of |\footstrutheight|. |
| 616 |
% But we prefer the universal notations for command names instead of strict one, |
| 617 |
% because users do not interested in implementation details. |
| 618 |
% \end{macro} |
| 619 |
% \end{macro} |
| 620 |
% \end{macro} |
| 621 |
% \end{macro} |
| 622 |
% |
| 623 |
% \begin{macro}{\headrule} |
| 624 |
% The default implementation of the |\headrule|. It works in vertical mode. |
| 625 |
% At first it draws a rule and then it inserts a negative skip for compensation. |
| 626 |
% \begin{macrocode} |
| 627 |
\newcommand{\headrule}{% |
| 628 |
\setlength\@tempdima{\headrulewidth}% |
| 629 |
\hrule\@height\@tempdima\@width\headwidth |
| 630 |
\vskip-\@tempdima |
| 631 |
} |
| 632 |
% \end{macrocode} |
| 633 |
% \end{macro} |
| 634 |
% |
| 635 |
% \begin{macro}{\footrule} |
| 636 |
% The |\footrule| works in reverse order: at first it inserts a negative skip |
| 637 |
% and after that it draws a rule. |
| 638 |
% \begin{macrocode} |
| 639 |
\newcommand{\footrule}{% |
| 640 |
\setlength\@tempdima{\footrulewidth}% Can use calc here |
| 641 |
\vskip -\@tempdima |
| 642 |
\hrule \@height\@tempdima \@width\headwidth |
| 643 |
} |
| 644 |
% \end{macrocode} |
| 645 |
% \end{macro} |
| 646 |
% |
| 647 |
% \begin{macro}{\NCC@fancyreset} |
| 648 |
% The |\NCC@fancyreset| command is used at the beginning |
| 649 |
% of fancy headers and footers. It resets font, removes |
| 650 |
% baseline stretch and locally defines the |\nouppercase| command. |
| 651 |
% In comparison with the |fancyhdr| package, we do not |
| 652 |
% call the |\restorecr| command because it is obsolete now. |
| 653 |
% We also redefine the |\uppercase| and |\MakeUppercase| |
| 654 |
% commands in more appropriate way than in |fancyhdr|. |
| 655 |
% \begin{macrocode} |
| 656 |
\def\NCC@fancyreset{\let\baselinestretch\@empty |
| 657 |
\long\def\nouppercase##1{% |
| 658 |
\begingroup |
| 659 |
\long\def\uppercase####1{####1}% |
| 660 |
\long\def\MakeUppercase####1{####1}% |
| 661 |
##1% |
| 662 |
\endgroup |
| 663 |
}% |
| 664 |
\reset@font |
| 665 |
} |
| 666 |
% \end{macrocode} |
| 667 |
% \end{macro} |
| 668 |
% |
| 669 |
% \begin{macro}{\NCC@fancyhead} |
| 670 |
% The |\NCC@fancyhead|\marg{left-mark}\marg{center-mark}\marg{right-mark} |
| 671 |
% command prepares the fancy header. It differs from the implementation in |
| 672 |
% the |fancyhdr| at the following issue: the vertical box in this command |
| 673 |
% (|\@tempboxa|) is prepared as |\vtop| box, but in the |fancyhdr| package |
| 674 |
% it is prepared as |\vbox| box. As a consequence, in the |fancyhdr| version, |
| 675 |
% the base line of the vertical box goes at the rule and the header slightly |
| 676 |
% moves up. |
| 677 |
% \begin{macrocode} |
| 678 |
\def\NCC@fancyhead#1#2#3{% |
| 679 |
\hb@xt@\headwidth{\NCC@fancyreset |
| 680 |
\setbox\@tempboxa\vtop{% |
| 681 |
\hbox{% |
| 682 |
% \end{macrocode} |
| 683 |
% Prepare the left mark: |
| 684 |
% \begin{macrocode} |
| 685 |
\rlap{\parbox[b]\headwidth{\raggedright#1}}% |
| 686 |
% \end{macrocode} |
| 687 |
% Insert the strut: |
| 688 |
% \begin{macrocode} |
| 689 |
\setlength\@tempdima{\headstrutheight}% |
| 690 |
\vrule\@width\z@\@height\z@\@depth\@tempdima |
| 691 |
% \end{macrocode} |
| 692 |
% Prepare the center mark: |
| 693 |
% \begin{macrocode} |
| 694 |
\parbox[b]\headwidth{\centering#2}% |
| 695 |
% \end{macrocode} |
| 696 |
% Prepare the right mark: |
| 697 |
% \begin{macrocode} |
| 698 |
\llap{\parbox[b]\headwidth{\raggedleft#3}}% |
| 699 |
}% |
| 700 |
% \end{macrocode} |
| 701 |
% Draw decoration rule: |
| 702 |
% \begin{macrocode} |
| 703 |
\headrule |
| 704 |
}% |
| 705 |
% \end{macrocode} |
| 706 |
% Compare the height of |\@tempboxa| with the |\headheaght| |
| 707 |
% and correct the last one if vertical overfull appears: |
| 708 |
% \begin{macrocode} |
| 709 |
\NCC@fancytest\headheight |
| 710 |
% \end{macrocode} |
| 711 |
% Put the fancy header: |
| 712 |
% \begin{macrocode} |
| 713 |
\box\@tempboxa |
| 714 |
}% |
| 715 |
} |
| 716 |
% \end{macrocode} |
| 717 |
% \end{macro} |
| 718 |
% |
| 719 |
% \begin{macro}{\NCC@fancyfoot} |
| 720 |
% The |\NCC@fancyfoot|\marg{left-mark}\marg{center-mark}\marg{right-mark} |
| 721 |
% command prepares the fancy footer. Its implementation is similar to |
| 722 |
% the |\NCC@fancyhead|. |
| 723 |
% \begin{macrocode} |
| 724 |
\def\NCC@fancyfoot#1#2#3{% |
| 725 |
\hb@xt@\headwidth{\NCC@fancyreset |
| 726 |
\setbox\@tempboxa\vbox{% |
| 727 |
\footrule |
| 728 |
\hbox{% |
| 729 |
\rlap{\parbox[t]\headwidth{\raggedright#1}}% |
| 730 |
\@tempdima .55\normalbaselineskip |
| 731 |
\addtolength\@tempdima{\footstrutheight}% |
| 732 |
\vrule\@width\z@\@height\@tempdima\@depth\z@ |
| 733 |
\parbox[t]\headwidth{\centering#2}% |
| 734 |
\llap{\parbox[t]\headwidth{\raggedleft#3}}% |
| 735 |
}% |
| 736 |
}% |
| 737 |
\NCC@fancytest\footskip |
| 738 |
\box\@tempboxa |
| 739 |
}% |
| 740 |
} |
| 741 |
% \end{macrocode} |
| 742 |
% \end{macro} |
| 743 |
% |
| 744 |
% \begin{macro}{\NCC@fancytest} |
| 745 |
% The |\NCC@fancytest|\marg{register} command compares |
| 746 |
% a value of the \meta{register} with the height of |\@tempboxa| |
| 747 |
% and modifies the \meta{register} value if necessary. |
| 748 |
% \begin{macrocode} |
| 749 |
\def\NCC@fancytest#1{% |
| 750 |
\ifdim\ht\@tempboxa>#1% |
| 751 |
\PackageWarning{nccfancyhdr}% |
| 752 |
{\string#1 is too small (\the#1):\MessageBreak |
| 753 |
Make it at least \the\ht\@tempboxa.\MessageBreak |
| 754 |
We now enlarge it for the rest of the document.\MessageBreak |
| 755 |
This may cause the page layout to be inconsistent, however}% |
| 756 |
\@tempdima#1\global\setlength{#1}{\ht\@tempboxa}% |
| 757 |
\ht\@tempboxa\@tempdima |
| 758 |
\fi |
| 759 |
} |
| 760 |
% \end{macrocode} |
| 761 |
% \end{macro} |
| 762 |
% |
| 763 |
% \begin{macro}{\NCC@ihss} |
| 764 |
% \begin{macro}{\NCC@ohss} |
| 765 |
% The |\NCC@ihss| and |\NCC@ohss| hooks insert the |\hss| command |
| 766 |
% at the outer and/or inner sides of header/footer to provide the proper |
| 767 |
% enlargement it on margins. |
| 768 |
% \begin{macrocode} |
| 769 |
\def\NCC@ihss{\if@twocolumn\hss\else\if@reversemargin\hss\fi\fi} |
| 770 |
\def\NCC@ohss{\if@twocolumn\hss\else\if@reversemargin\else\hss\fi\fi} |
| 771 |
% \end{macrocode} |
| 772 |
% \end{macro} |
| 773 |
% \end{macro} |
| 774 |
% |
| 775 |
% \begin{macro}{\fancycenter} |
| 776 |
% |\fancycenter|\oarg{dist}\oarg{stretch}\marg{left-mark}\marg{center-mark}\marg{right-mark} |
| 777 |
% \begin{macrocode} |
| 778 |
\newcommand*{\fancycenter}[1][1em]{% |
| 779 |
\@ifnextchar[{\NCC@fancycenter{#1}}{\NCC@fancycenter{#1}[3]}% |
| 780 |
} |
| 781 |
\def\NCC@fancycenter#1[#2]#3#4#5{% |
| 782 |
% \end{macrocode} |
| 783 |
% At first, we execute the case when the \meta{center-mark} is empty: |
| 784 |
% \begin{macrocode} |
| 785 |
\def\@tempa{#4}\ifx\@tempa\@empty |
| 786 |
\hb@xt@\linewidth{\color@begingroup{#3}\hfil {#5}\color@endgroup}% |
| 787 |
\else |
| 788 |
% \end{macrocode} |
| 789 |
% All that we need to do is to calculate skips inserted before and after |
| 790 |
% \meta{center-mark}. We will calculate them in the |\@tempskipa| |
| 791 |
% and |\@tempskipb|. At first: |
| 792 |
% \begin{quote} |
| 793 |
% |\@tempdima:=|\meta{dist};\\ |
| 794 |
% |\@tempdimb:=|\meta{dist}|*|\meta{stretch};\\ |
| 795 |
% |\@tempdimc:=|\meta{dist}|*|\meta{stretch}|-|\meta{dist};\\ |
| 796 |
% |\@tempskipa:=\@tempskipb:=\@tempdimb + 1fil - \@tempdimc|; |
| 797 |
% \end{quote} |
| 798 |
% \begin{macrocode} |
| 799 |
\setlength\@tempdima{#1}% |
| 800 |
\setlength{\@tempdimb}{#2\@tempdima}% |
| 801 |
\@tempdimc \@tempdimb \advance\@tempdimc -\@tempdima |
| 802 |
\setlength\@tempskipa{\@tempdimb \@plus 1fil \@minus \@tempdimc}% |
| 803 |
\@tempskipb\@tempskipa |
| 804 |
% \end{macrocode} |
| 805 |
% At this point, the |\@tempskipa| and |\@tempskipb| registers |
| 806 |
% have the natural size \meta{dist}|*|\meta{stretch}, |
| 807 |
% unlimited stretchability, and the minimum size \meta{dist}. |
| 808 |
% Now we decrease the minimum size of |\@tempskipa| to zero if |
| 809 |
% the \meta{left-mark} is empty: |
| 810 |
% \begin{macrocode} |
| 811 |
\def\@tempa{#3}\ifx\@tempa\@empty |
| 812 |
\addtolength\@tempskipa{\z@ \@minus \@tempdima}% |
| 813 |
\fi |
| 814 |
% \end{macrocode} |
| 815 |
% Do the same things with the |\@tempskipb| register if the |
| 816 |
% \meta{right-mark} is empty: |
| 817 |
% \begin{macrocode} |
| 818 |
\def\@tempa{#5}\ifx\@tempa\@empty % empty right |
| 819 |
\addtolength\@tempskipb{\z@ \@minus \@tempdima}% |
| 820 |
\fi |
| 821 |
% \end{macrocode} |
| 822 |
% Finally, we correct the left and right glues taking into |
| 823 |
% account the difference between lengthes of \meta{left-mark} |
| 824 |
% and \meta{right-mark}. We calculate what mark is shorter |
| 825 |
% and increase the natural size of corresponding register |
| 826 |
% on the difference between their lengthes. |
| 827 |
% \begin{macrocode} |
| 828 |
\settowidth{\@tempdimb}{#3}% |
| 829 |
\settowidth{\@tempdimc}{#5}% |
| 830 |
\ifdim\@tempdimb>\@tempdimc |
| 831 |
\advance\@tempdimb -\@tempdimc |
| 832 |
\addtolength\@tempskipb{\@tempdimb \@minus \@tempdimb}% |
| 833 |
\else |
| 834 |
\advance\@tempdimc -\@tempdimb |
| 835 |
\addtolength\@tempskipa{\@tempdimc \@minus \@tempdimc}% |
| 836 |
\fi |
| 837 |
% \end{macrocode} |
| 838 |
% The |\@tempskipa| and |\@tempskipb| are calculated. Put the box. |
| 839 |
% \begin{macrocode} |
| 840 |
\hb@xt@\linewidth{\color@begingroup{#3}\hskip \@tempskipa |
| 841 |
{#4}\hskip \@tempskipb {#5}\color@endgroup}% |
| 842 |
\fi |
| 843 |
} |
| 844 |
% \end{macrocode} |
| 845 |
% \end{macro} |
| 846 |
% |
| 847 |
% The rest of the package consists of games with styles and options. |
| 848 |
% |
| 849 |
% \begin{macro}{\ps@fancy} |
| 850 |
% We start from declaring the |fancy| page style. It extends the |
| 851 |
% |empty| page style. So, we simply call the empty style and then |
| 852 |
% redefine |\@oddhead|, |\@evenhead|, |\@oddfoot|, and |\@evenfoot| |
| 853 |
% to be fancy one. The |\NCC@ihss| and |\NCC@ohss| hooks provide |
| 854 |
% proper enlargement of headers/footers on margins. The |\fancyhf{}| |
| 855 |
% command at the end of macro clears all marks. |
| 856 |
% \begin{macrocode} |
| 857 |
\def\ps@fancy{\ps@empty |
| 858 |
\def\@oddhead{% |
| 859 |
\NCC@ihss \NCC@fancyhead\NCC@f@olh\NCC@f@och\NCC@f@orh \NCC@ohss}% |
| 860 |
\def\@evenhead{% |
| 861 |
\NCC@ohss \NCC@fancyhead\NCC@f@elh\NCC@f@ech\NCC@f@erh \NCC@ihss}% |
| 862 |
\def\@oddfoot{% |
| 863 |
\NCC@ihss \NCC@fancyfoot\NCC@f@olf\NCC@f@ocf\NCC@f@orf \NCC@ohss}% |
| 864 |
\def\@evenfoot{% |
| 865 |
\NCC@ohss \NCC@fancyfoot\NCC@f@elf\NCC@f@ecf\NCC@f@erf \NCC@ihss}% |
| 866 |
\fancyhf{}% |
| 867 |
} |
| 868 |
% \end{macrocode} |
| 869 |
% \end{macro} |
| 870 |
% |
| 871 |
% Standard styles are redefined optionally. |
| 872 |
% |
| 873 |
% \begin{macro}{\ps@empty} |
| 874 |
% When we redefine the |empty| style, we must take into account |
| 875 |
% that it can be also redefined (as in |amsart| and |amsbook| classes). |
| 876 |
% So, we save its previous meaning in the |\NCC@psempty| macro and base the |
| 877 |
% |empty| style on the saved style. |
| 878 |
% \begin{macrocode} |
| 879 |
\DeclareOption{empty}{% |
| 880 |
\let\NCC@psempty\ps@empty |
| 881 |
\def\ps@empty{\NCC@psempty |
| 882 |
\def\@oddhead{% |
| 883 |
\NCC@ihss \NCC@fancyhead\NCC@f@olh\NCC@f@och\NCC@f@orh \NCC@ohss}% |
| 884 |
\def\@evenhead{% |
| 885 |
\NCC@ohss \NCC@fancyhead\NCC@f@elh\NCC@f@ech\NCC@f@erh \NCC@ihss}% |
| 886 |
\def\@oddfoot{% |
| 887 |
\NCC@ihss \NCC@fancyfoot\NCC@f@olf\NCC@f@ocf\NCC@f@orf \NCC@ohss}% |
| 888 |
\def\@evenfoot{% |
| 889 |
\NCC@ohss \NCC@fancyfoot\NCC@f@elf\NCC@f@ecf\NCC@f@erf \NCC@ihss}% |
| 890 |
\fancyhf{}% |
| 891 |
}% |
| 892 |
\pagestyle{empty}% |
| 893 |
} |
| 894 |
% \end{macrocode} |
| 895 |
% \end{macro} |
| 896 |
% |
| 897 |
% \begin{macro}{\ps@plain} |
| 898 |
% The redefinition of the |plain| style is quite simple: |
| 899 |
% \begin{macrocode} |
| 900 |
\DeclareOption{plain}{% |
| 901 |
\def\ps@plain{\ps@fancy \let\@mkboth\@gobbletwo |
| 902 |
\fancyfoot[c]{\thepage}% |
| 903 |
}% |
| 904 |
\pagestyle{plain}% |
| 905 |
} |
| 906 |
% \end{macrocode} |
| 907 |
% \end{macro} |
| 908 |
% |
| 909 |
% \begin{macro}{\ps@myheadings} |
| 910 |
% The redefinition of the |myheadings| style is conditional. |
| 911 |
% We test the |\chapter| command on existence and redefine the |
| 912 |
% style in a bit different ways. |
| 913 |
% \begin{macrocode} |
| 914 |
\DeclareOption{myheadings}{% |
| 915 |
\@ifundefined{chapter}{% |
| 916 |
\def\ps@myheadings{\ps@fancy \let\@mkboth\@gobbletwo |
| 917 |
\fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% |
| 918 |
\fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% |
| 919 |
\let\sectionmark\@gobble |
| 920 |
\let\subsectionmark\@gobble |
| 921 |
}% |
| 922 |
}{\def\ps@myheadings{\ps@fancy \let\@mkboth\@gobbletwo |
| 923 |
\fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% |
| 924 |
\fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% |
| 925 |
\let\chaptermark\@gobble |
| 926 |
\let\sectionmark\@gobble |
| 927 |
}% |
| 928 |
}% |
| 929 |
\pagestyle{myheadings}% |
| 930 |
} |
| 931 |
% \end{macrocode} |
| 932 |
% \end{macro} |
| 933 |
% |
| 934 |
% \begin{macro}{\ps@headings} |
| 935 |
% The redefinition of the |headings| style also differs for |
| 936 |
% book-like and article-like classes. It also differs for |
| 937 |
% one-side and two-side modes. |
| 938 |
% \begin{macrocode} |
| 939 |
\DeclareOption{headings}{% |
| 940 |
\@ifundefined{chapter}{% |
| 941 |
\if@twoside |
| 942 |
% \end{macrocode} |
| 943 |
% An article in two-side mode: |
| 944 |
% \begin{macrocode} |
| 945 |
\def\ps@headings{\ps@fancy \let\@mkboth\markboth |
| 946 |
\fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% |
| 947 |
\fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% |
| 948 |
\def\sectionmark##1{% |
| 949 |
\markboth{\MakeUppercase{% |
| 950 |
\ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}{}}% |
| 951 |
\def\subsectionmark##1{% |
| 952 |
\markright{% |
| 953 |
\ifnum \c@secnumdepth >\@ne \thesubsection\quad \fi##1}}% |
| 954 |
}% |
| 955 |
\else |
| 956 |
% \end{macrocode} |
| 957 |
% An article in one-side mode: |
| 958 |
% \begin{macrocode} |
| 959 |
\def\ps@headings{\ps@fancy \let\@mkboth\markboth |
| 960 |
\fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% |
| 961 |
\fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% |
| 962 |
\def\sectionmark##1{% |
| 963 |
\markright {\MakeUppercase{% |
| 964 |
\ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}}% |
| 965 |
\let\subsectionmark\@gobble % Not needed but inserted for safety |
| 966 |
}% |
| 967 |
\fi |
| 968 |
}{\if@twoside |
| 969 |
% \end{macrocode} |
| 970 |
% A book in two-side mode: |
| 971 |
% \begin{macrocode} |
| 972 |
\def\ps@headings{\ps@fancy \let\@mkboth\markboth |
| 973 |
\fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% |
| 974 |
\fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% |
| 975 |
\def\chaptermark##1{% |
| 976 |
\markboth{\MakeUppercase{% |
| 977 |
\ifnum \c@secnumdepth >\m@ne \if@mainmatter |
| 978 |
\@chapapp\ \thechapter. \ \fi\fi##1}}{}}% |
| 979 |
\def\sectionmark##1{% |
| 980 |
\markright {\MakeUppercase{% |
| 981 |
\ifnum \c@secnumdepth >\z@ \thesection. \ \fi##1}}}% |
| 982 |
}% |
| 983 |
\else |
| 984 |
% \end{macrocode} |
| 985 |
% A book in one-side mode: |
| 986 |
% \begin{macrocode} |
| 987 |
\def\ps@headings{\ps@fancy \let\@mkboth\markboth |
| 988 |
\fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% |
| 989 |
\fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% |
| 990 |
\def\chaptermark##1{% |
| 991 |
\markright{\MakeUppercase{% |
| 992 |
\ifnum \c@secnumdepth >\m@ne \if@mainmatter |
| 993 |
\@chapapp\ \thechapter. \ \fi\fi##1}}}% |
| 994 |
\let\sectionmark\@gobble % Not needed but inserted for safety |
| 995 |
}% |
| 996 |
\fi |
| 997 |
}% |
| 998 |
\pagestyle{headings}% |
| 999 |
} |
| 1000 |
% \end{macrocode} |
| 1001 |
% \end{macro} |
| 1002 |
% |
| 1003 |
% \begin{macro}{\iffloatpage} |
| 1004 |
% \begin{macro}{\iftopfloat} |
| 1005 |
% \begin{macro}{\ifbotfloat} |
| 1006 |
% These macros are defined in the |testfloats| option. |
| 1007 |
% They were ported from the |fancyhdr| and modified a bit |
| 1008 |
% in more \LaTeX\ way. It is no warrantee that these macros |
| 1009 |
% will proper work in all cases. They must be used inside |
| 1010 |
% fancy mark commands. |
| 1011 |
% \begin{macrocode} |
| 1012 |
\DeclareOption{testfloats}{% |
| 1013 |
\let\NCC@fancymakecol\@makecol |
| 1014 |
\let\NCC@fancytoplist\@empty |
| 1015 |
\let\NCC@fancybotlist\@empty |
| 1016 |
\def\@makecol{% |
| 1017 |
\let\NCC@fancytoplist\@toplist |
| 1018 |
\let\NCC@fancybotlist\@botlist |
| 1019 |
\NCC@fancymakecol |
| 1020 |
}% |
| 1021 |
\newcommand\iftopfloat{% |
| 1022 |
\ifx\NCC@fancytoplist\@empty |
| 1023 |
\expandafter\@secondoftwo |
| 1024 |
\else |
| 1025 |
\expandafter\@firstoftwo |
| 1026 |
\fi |
| 1027 |
}% |
| 1028 |
\newcommand\ifbotfloat{% |
| 1029 |
\ifx\NCC@fancybotlist\@empty |
| 1030 |
\expandafter\@secondoftwo |
| 1031 |
\else |
| 1032 |
\expandafter\@firstoftwo |
| 1033 |
\fi |
| 1034 |
}% |
| 1035 |
\newcommand\iffloatpage{% |
| 1036 |
\if@fcolmade |
| 1037 |
\expandafter\@firstoftwo |
| 1038 |
\else |
| 1039 |
\expandafter\@secondoftwo |
| 1040 |
\fi |
| 1041 |
}% |
| 1042 |
} |
| 1043 |
% \end{macrocode} |
| 1044 |
% \end{macro} |
| 1045 |
% \end{macro} |
| 1046 |
% \end{macro} |
| 1047 |
% |
| 1048 |
% Finally, we process the options in the order they are specified |
| 1049 |
% in the options list and set the defaults. |
| 1050 |
% \begin{macrocode} |
| 1051 |
\ProcessOptions* |
| 1052 |
\normalheaders |
| 1053 |
\fancyhf{} |
| 1054 |
%</package> |
| 1055 |
% \end{macrocode} |
| 1056 |
\endinput |