f244fa85d1e4c7231e5e51deca1e440ffdfec483
[alexxy/gromacs.git] / manual / fancy.sty
1 % fancyheadings.sty version 1.0
2 % Fancy headers and footers.
3 % Piet van Oostrum, Dept of Computer Science, University of Utrecht
4 % Padualaan 14, P.O. Box 80.089, 3508 TB Utrecht, The Netherlands
5 % Telephone: +31-30-531806. piet@cs.ruu.nl (mcvax!hp4nl!ruuinf!piet)
6 % March, 1989.
7
8 % Here is a documentstylestyle option that allows you to customize your
9 % page headers and footers in an easy way. It combines features that were
10 % separately available in other pagestyles, without introducing much
11 % complexity. You can define:
12 %     - three-part headers and footers
13 %     - rules in header and footer
14 %     - headers and footers wider than \textwidth
15 %     - multiline headers and footers
16 %     - separate headers and footers for even and odd pages
17 %     - separate headers and footers for chapter pages
18
19 % To use this pagestyle, you must include the ``fancyheadings'' style
20 % option in your \documentstyle, and issue the \pagestyle{fancy} command.
21 % The \pagestyle{fancy} command should be issued after any changes made to
22 % \textwidth.
23
24 % The page layout will be as follows:
25
26 %               LHEAD          CHEAD          RHEAD
27 %               ----------------------------------- (rule)
28
29 %                            page body
30
31
32 %               ----------------------------------- (rule)
33 %               LFOOT          CFOOT          RFOOT
34
35 % The L-fields will be leftadjusted, the C-fields centered and the
36 % R-fields rightadjusted.
37 % Each of the six fields and the two rules can be defined separately.
38
39 % Simple use:
40
41 % The header and footer fields can be defined by commands \lhead{LHEAD}
42 % and so on for the other fields. If the field depends on something in the
43 % document (e.g. section titles) you must in general use the \markboth and
44 % \markright commands, otherwise a title may end on the wrong page. You
45 % can do this e.g. by redefining the commands \chaptermark, \sectionmark
46 % and so on (see example below). The defaults for these marks are as in
47 % the standard pagestyles. The marks can be put into a header or footer
48 % field by referencing \leftmark and \rightmark.
49
50 % Rules in header and footer
51
52 % The thickness of the rules below the header and above the footer can be
53 % changed by redefining the length parameters \headrulewidth (default
54 % 0.4pt) and \footrulewidth (default 0). These may be redefined by the
55 % \setlength command. A thickness of 0pt makes the rule invisible.
56 % If you want to make more complicated changes, you have to redefine the
57 % commands \headrule and/or \footrule.
58
59 % Headers and footers wider than \textwidth
60
61 % The headers and footers are set in a box of width \headwidth. The
62 % default for this is the value of \textwidth. You can make it wider (or
63 % smaller) by redefining \headwidth with the \setlength or \addtolength
64 % command. The headers and footers will stick out the page on the same
65 % side as the marginal notes. For example to include the marginal notes,
66 % add both \marginparsep and \marginparwidth to \headwidth (see also the
67 % example below).
68
69 % Multiline headers and footers
70
71 % Each of the six fields is set in an appropriate parbox, so you can put a
72 % multiline part in it with the \\ command. It is also possible to put
73 % extra space in it with the \vspace command. Note that if you do this you
74 % will probably have to increase the \headheight or \footskip lengths.
75
76 % Separate headers and footers for even and odd pages
77
78 % If you want the headers and footers to be different on even- and
79 % odd-numbered pages in the ``twoside'' style, the field-defining macros
80 % can be given an optional argument, to be used on the even-numbered
81 % pages, like \lhead[EVEN-LHEAD]{ODD-RHEAD}.
82
83 % Separate headers and footers for chapter pages
84
85 % LaTeX gives a \thispagestyle{plain} command for the first page of the
86 % document, the first page of each chapter and a couple of other pages. It
87 % might be incompatible with your pagestyle. In this case you can use a
88 % slightly different version of the pagestyle, called \pagestyle{fancyplain}. 
89 % This pagestyle redefines the pagestyle ``plain'' to also use pagestyle
90 % ``fancy'' with the following modifications:
91 %     - the thicknesses of the rules is defined by \plainheadrulewidth and
92 %       \plainfootrulewidth (both default 0).
93 %     - the 6 fields may be defined separately for the plain pages by
94 %       giving them the value \fancyplain{PLAIN-VALUE}{NORMAL-VALUE}. This
95 %       construct may be used in both the optional argument and the normal
96 %       argument. Thus \lhead[\fancyplain{F1}{F2}]{\fancyplain{F3}{F4}}
97 %       specifies the LHEAD value in a two-sided document:
98 %       F1 on an even-numbered ``plain'' page
99 %       F2 on an even-numbered normal page
100 %       F3 on an odd-numbered ``plain'' page
101 %       F4 on an odd-numbered normal page.
102
103 % Defaults:
104
105 % \headrulewidth              0.4pt
106 % \footrulewidth                0pt
107 % \plainheadrulewidth   0pt
108 % \plainfootrulewidth   0pt
109
110 % \lhead[\fancyplain{}{\sl\rightmark}]{\fancyplain{}{\sl\leftmark}}
111 % %  i.e. empty on ``plain'' pages \rightmark on even, \leftmark on odd pages
112 % \chead{}
113 % \rhead[\fancyplain{}{\sl\leftmark}]{\fancyplain{}{\sl\rightmark}}
114 % %  i.e. empty on ``plain'' pages \leftmark on even, \rightmark on odd pages
115 % \lfoot{}
116 % \cfoot{\rm\thepage} % page number
117 % \rfoot{}
118
119 % Examples:
120
121 % To put two lines containing the section title and the subsection title
122 % in the righthandside corner, use:
123
124 % \documentstyle[fancyheadings]{article}
125 % \pagestyle{fancy}
126 % \renewcommand{\sectionmark}[1]{\markboth{#1}{}}
127 % \renewcommand{\subsectionmark}[1]{\markright{#1}}
128 % \rfoot{\leftmark\\\rightmark}
129
130 % The following definitions give an approximation of the style used in the
131 % LaTeX book:
132
133 % \documentstyle[fancyheadings]{book}
134 % \pagestyle{fancyplain}
135 % \addtolength{\headwidth}{\marginparsep}
136 % \addtolength{\headwidth}{\marginparwidth}
137 % \renewcommand{\chaptermark}[1]{\markboth{#1}{#1}} % remember chapter title
138 % \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
139 %                                                 % section number and title
140 % \lhead[\fancyplain{}{\bf\thepage}]{\fancyplain{}{\bf\rightmark}}
141 % \rhead[\fancyplain{}{\bf\leftmark}]{\fancyplain{}{\bf\thepage}}
142 % \cfoot{}
143
144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145 \def\lhead{\@ifnextchar[{\@xlhead}{\@ylhead}}
146 \def\@xlhead[#1]#2{\gdef\@elhead{#1}\gdef\@olhead{#2}}
147 \def\@ylhead#1{\gdef\@elhead{#1}\gdef\@olhead{#1}}
148
149 \def\chead{\@ifnextchar[{\@xchead}{\@ychead}}
150 \def\@xchead[#1]#2{\gdef\@echead{#1}\gdef\@ochead{#2}}
151 \def\@ychead#1{\gdef\@echead{#1}\gdef\@ochead{#1}}
152
153 \def\rhead{\@ifnextchar[{\@xrhead}{\@yrhead}}
154 \def\@xrhead[#1]#2{\gdef\@erhead{#1}\gdef\@orhead{#2}}
155 \def\@yrhead#1{\gdef\@erhead{#1}\gdef\@orhead{#1}}
156
157 \def\lfoot{\@ifnextchar[{\@xlfoot}{\@ylfoot}}
158 \def\@xlfoot[#1]#2{\gdef\@elfoot{#1}\gdef\@olfoot{#2}}
159 \def\@ylfoot#1{\gdef\@elfoot{#1}\gdef\@olfoot{#1}}
160
161 \def\cfoot{\@ifnextchar[{\@xcfoot}{\@ycfoot}}
162 \def\@xcfoot[#1]#2{\gdef\@ecfoot{#1}\gdef\@ocfoot{#2}}
163 \def\@ycfoot#1{\gdef\@ecfoot{#1}\gdef\@ocfoot{#1}}
164
165 \def\rfoot{\@ifnextchar[{\@xrfoot}{\@yrfoot}}
166 \def\@xrfoot[#1]#2{\gdef\@erfoot{#1}\gdef\@orfoot{#2}}
167 \def\@yrfoot#1{\gdef\@erfoot{#1}\gdef\@orfoot{#1}}
168
169 \newdimen\headrulewidth
170 \newdimen\footrulewidth
171 \newdimen\plainheadrulewidth
172 \newdimen\plainfootrulewidth
173 \newdimen\headwidth
174 \newif\if@fancyplain \@fancyplainfalse
175 \def\fancyplain#1#2{\if@fancyplain#1\else#2\fi}
176
177 % Initialization of the head and foot text.
178
179 \headrulewidth 0.4pt
180 \footrulewidth\z@
181 \plainheadrulewidth\z@
182 \plainfootrulewidth\z@
183
184 \lhead[\fancyplain{}{\sl\rightmark}]{\fancyplain{}{\sl\leftmark}}
185 %  i.e. empty on ``plain'' pages \rightmark on even, \leftmark on odd pages
186 \chead{}
187 \rhead[\fancyplain{}{\sl\leftmark}]{\fancyplain{}{\sl\rightmark}}
188 %  i.e. empty on ``plain'' pages \leftmark on even, \rightmark on odd pages
189 \lfoot{}
190 \cfoot{\rm\thepage} % page number
191 \rfoot{}
192
193 % Put together a header or footer given the left, center and
194 % right text, fillers at left and right and a rule.
195 % The \lap commands put the text into an hbox of zero size,
196 % so overlapping text does not generate an errormessage.
197
198 \def\@fancyhead#1#2#3#4#5{#1\hbox to\headwidth{\vbox{\hbox
199 {\rlap{\parbox[b]{\headwidth}{\raggedright#2\strut}}\hfill
200 \parbox[b]{\headwidth}{\centering#3\strut}\hfill
201 \llap{\parbox[b]{\headwidth}{\raggedleft#4\strut}}}\headrule}}#5}
202
203
204 \def\@fancyfoot#1#2#3#4#5{#1\hbox to\headwidth{\vbox{\footrule
205 \hbox{\rlap{\parbox[t]{\headwidth}{\raggedright#2\strut}}\hfill
206 \parbox[t]{\headwidth}{\centering#3\strut}\hfill
207 \llap{\parbox[t]{\headwidth}{\raggedleft#4\strut}}}}}#5}
208
209 \def\headrule{{\if@fancyplain\headrulewidth\plainheadrulewidth\fi
210 \hrule\@height\headrulewidth\@width\headwidth \vskip-\headrulewidth}}
211
212 \def\footrule{{\if@fancyplain\footrulewidth\plainfootrulewidth\fi
213 \vskip-0.3\normalbaselineskip\vskip-\footrulewidth
214 \hrule\@width\headwidth\@height\footrulewidth\vskip0.3\normalbaselineskip}}
215
216 \def\ps@fancy{
217 \let\@mkboth\markboth
218 \@ifundefined{chapter}{\def\sectionmark##1{\markboth
219 {\ifnum \c@secnumdepth>\z@
220  \thesection\hskip 1em\relax \fi ##1}{}}
221 \def\subsectionmark##1{\markright {\ifnum \c@secnumdepth >\@ne
222  \thesubsection\hskip 1em\relax \fi ##1}}}
223 {\def\chaptermark##1{\markboth {\ifnum \c@secnumdepth>\m@ne
224  \@chapapp\ \thechapter. \ \fi ##1}{}}
225 \def\sectionmark##1{\markright{\ifnum \c@secnumdepth >\z@
226  \thesection. \ \fi ##1}}}
227 \def\@oddhead{\@fancyhead\relax\@olhead\@ochead\@orhead\hss}
228 \def\@oddfoot{\@fancyfoot\relax\@olfoot\@ocfoot\@orfoot\hss}
229 \def\@evenhead{\@fancyhead\hss\@elhead\@echead\@erhead\relax}
230 \def\@evenfoot{\@fancyfoot\hss\@elfoot\@ecfoot\@erfoot\relax}
231 \headwidth\textwidth}
232 \def\ps@fancyplain{\ps@fancy \let\ps@plain\ps@plain@fancy}
233 \def\ps@plain@fancy{\@fancyplaintrue\ps@fancy}