summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/fancyhdr/fancyhdr.tex
blob: 0b4c0527a5fa1a7b33e95a8082cc3e4e2d6ba4ad (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
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
\documentclass[a4paper]{article}
\usepackage{multicol}
\usepackage{float}
\usepackage{makeidx}
\usepackage{layout}
\usepackage{array}
\usepackage{a4wide}
\usepackage{boxedminipage}
\usepackage{fourier-orns}
\makeindex
\title{Page layout in \LaTeX}
\author{Piet van Oostrum\thanks{A considerable part of this article was
    written by  George
    Gr\"atzer (University of Manitoba) in \emph{Notices Amer. Math. Soc.}
    Thanks, George!}\\
  Dept.\ of Computer Science\thanks{This was my employer at the time I developed this package. I am now retired.}\\
  Utrecht University}
\def\latex/{\protect\LaTeX{}}
\def\tex/{\TeX}
\def\ams/{\protect\pAmS}
\def\pAmS{{\the\textfont2
        A\kern-.1667em\lower.5ex\hbox{M}\kern-.125emS}}
\def\amslatex/{\ams/-\latex/}
\newcommand{\PSNFSS}{{\sf
    PSNFSS}}
\newcommand{\bs}{\symbol{'134}}
\newcommand{\Cmd}[1]{\texttt{\def\{{\char`\{}\def\}{\char`\}}\bs#1}}
\newcommand{\CmdIndex}[1]{\index{#1@\string\texttt{\bs#1}}}
\newcommand{\TTindex}[1]{\index{#1@\string\texttt{#1}}}
\newcommand{\PSindex}[1]{\index{page style!#1@\string\texttt{#1}}}
%\floatstyle{ruled}
\restylefloat{figure}
\renewcommand{\topfraction}{0.9}
\renewcommand{\bottomfraction}{0.9}
\renewcommand{\textfraction}{0.05}
\setlength{\parindent}{0pt}
\setlength{\parskip}{1ex}
\setlength{\emergencystretch}{4em}
\addtolength{\textheight}{-0.5in} % make it print better on US letter paper
\makeatletter
\renewcommand\l@section      {\@dottedtocline{1}{1.5em}{2.3em}}
\makeatother
\newenvironment{block}{\vspace{8pt}\begin{minipage}{\textwidth}}{\end{minipage}\vspace{8pt}}
\newenvironment{fblock}{\vspace{8pt}\begin{boxedminipage}{\textwidth}}{\end{boxedminipage}\vspace{8pt}}
\begin{document}
\maketitle
\begin{abstract}
  This article describes how to customize the page layout of your LaTeX
  documents, i.e how to change page margings and sizes, 
  headers and footers, and the
  proper placement of figures and tables (collectively called floats) on
  the page. 

  Originally this was the documentation of the  \textsf{fancyheadings}
  package. It did contain also other info, e.g. advanced use of marks.
  It has now been upgraded to include more, e.g. the handling of floats.
  The documentation describes version 3.6 or later of the \textsf{fancyhdr} package 
  and version 2.1 or later of the \textsf{extramarks} package.

\end{abstract}
\tableofcontents


\section{Introduction}
\label{sec:intro}

A page in a \LaTeX{} document is built from various elements as shown in
figure \ref{fig:layout}. 
\begin{figure}[htbp]
  \begin{center}
    \leavevmode
    \layout
    \vspace{3cm}
    \caption{Page elements. The values shown are those in effect in the current document, not the defaults.}
    \label{fig:layout}
  \end{center}
\end{figure}
%\thispagestyle{fancy}
\thispagestyle{plain}
The body contains the main text of the document
together with the so called floats (tables and figures). 

The pages are constructed by \LaTeX's output routine, which is quite
complicated and should therefore not be modified. Some of the packages
described in this paper contains small modifications to the output routine
to accomplish things that cannot be done in another way. You should use
these packages to get the desired result rather than fiddling with the
output routine yourself.

There are a number of things that you must be aware of:
\begin{enumerate}
\item The margins on the left are not called \Cmd{leftmargin}, but
  \Cmd{evensidemargin} (on even-numbered pages) and \Cmd{oddsidemargin}
  (on odd-numbered pages). In one-sided documents 
  \Cmd{oddsidemargin} is used for either.  \Cmd{leftmargin} is also a valid
  \latex/ parameter but it has a different use (namely the indentation of
  lists). 
\item Most of the parameters should not be changed in the middle of a
  document. Some changes might work at a pagebreak. If you want to change
  the height of a single page, you can use the \Cmd{enlargethispage}
  command. 
\end{enumerate}

The margin notes
area contains small pieces of information created by the \Cmd{marginpar}
command. On twosided documents the margin notes appear on the left and right
alternatively. The margin notes are not on fixed places with respect to the
paper but at approximately the same height as the paragraph in which they
appear. Due to the algorithm used to decide the placement of margin notes,
in a twosided document unfortunately 
they may appear on the wrong side if they are close
to a page break.
If you want to put information on fixed places in the margins you may use
the technique described in sections \ref{sec:movie} and \ref{sec:thumb}.

The first part of this paper describes how to change the header and footer
areas. The last part describes how to get your floats at the desired place.

\section{Page headers and footers}

The page headers and footers in \LaTeX{} are defined by the
\Cmd{pagestyle} and \Cmd{pagenumbering} commands. \Cmd{pagestyle}
defines the general contents of the headers and footers (e.g. where the
page number will be printed), while
\Cmd{pagenumbering} defines the format of the page number.
\LaTeX{} has four standard pagestyles:

\begin{tabular}{>{\tt}lp{10cm}}
empty & no headers or footers \\
plain & no header, footer contains page number centered \\
headings & no footer, header contains name of chapter/section and/or
subsection and page number \\
myheadings & no footer, header contains page number and user supplied information
\end{tabular}

Although these are useful styles, they are quite limited. Additional page
styles can be defined by defining commands of the form \Cmd{ps@xxx}. This
command is executed when a \Cmd{pagestyle\{xxx\}} is given in the document.
The  \Cmd{ps@xxx} command should define the following 
commands for the contents of the headers and footers:

\noindent
\begin{tabular}{lp{10cm}}
\Cmd{@oddhead} & header on odd numbered pages in two-sided documents
(on all pages in one-sided) \\
\Cmd{@evenhead} & header on even numbered pages in two-sided documents \\
\Cmd{@oddfoot} & footer on odd numbered pages in two-sided documents
(on all pages in one-sided) \\
\Cmd{@evenfoot} & footer on even numbered pages in two-sided documents \\
\end{tabular}

These are not user commands, but rather ``variables'' that are used by
\latex/'s output routine.
As the command names contain the character '\texttt{@}', they should
be defined in a package file, or otherwise be sandwiched between the commands
\Cmd{makeatletter} and \Cmd{makeatother}.

The \Cmd{pagenumbering} command defines the layout of the page number. It
has a parameter from the following list:

\begin{tabular}{>{\tt}ll}
arabic & arabic numerals \\
roman & lower case roman numerals \\
Roman & upper case roman numerals \\
alph & lower case letter \\
Alph & upper case letter
\end{tabular}

The  \Cmd{pagenumbering\{xxx\}} defines the command \Cmd{thepage} to be the
expansion of the page number in the given notation \texttt{xxx}. 
The pagestyle command
then would include \Cmd{thepage} in the appropriate place. Additionally
the  \Cmd{pagenumbering} command resets the page number to~1.
The  \Cmd{pagestyle} and  \Cmd{pagenumbering} apply to the page that is
being constructed, so they should be used at a location where it is clear
to what page they apply (see section \ref{sec:change}).


\section{What is \textsf{fancyhdr}}

The \textsf{fancyhdr} macro package allows you to customize
in \latex/ your page headers and footers in an easy way.  You can
define:
\begin{itemize}
\item three-part headers and footers
\item decorative lines in headers and footers
\item headers and footers wider than the width of the text
\item multi-line headers and footers
\item separate headers and footers for even and odd pages
\item different headers and footers for chapter pages
\item different headers and footer on pages with floats
\end{itemize}

Of course, you also have complete control over fonts, uppercase
and lowercase displays, etc.

\section{Simple use of \textsf{fancyhdr}}  To use this package in a
\LaTeXe\ document, place the file \verb|fancyhdr.sty| in a
directory/folder where \tex/ can find it (normally in the input
directory/folder), and include in the preamble of your document
after

\begin{verbatim}
\documentclass{...}
\end{verbatim}
the commands: 

\PSindex{fancy}
\begin{verbatim}
\usepackage{fancyhdr}
\pagestyle{fancy}
\end{verbatim}

We can visualize the page layout we can create with \textsf{fancyhdr}
as follows:

\begin{fblock}
\noindent\makebox[\textwidth]{LeftHeader\hfill
CenteredHeader\hfill RightHeader}
\noindent\makebox[\textwidth]{\hrulefill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hfill page body\hfill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hrulefill}
\noindent\makebox[\textwidth]{LeftFooter\hfill
CenteredFooter\hfill RightFooter}
\end{fblock}

The LeftHeader and LeftFooter are left justified; the
CenteredHeader and CenteredFooter are centered; the
RightHeader and RightFooter are right justified.

We define each of the six ``fields'' and the two decorative lines
separately.

\section{A simple example}  K. Grant is writing a report to Dean
A. Smith, on ``The performance of new graduates'' with the
following page layout:

\begin{fblock}
\noindent\makebox[\textwidth]{\hfill\textbf{The performance of new
graduates}}
\noindent\makebox[\textwidth]{\hrulefill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hfill page body\hfill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hrulefill}
\noindent\makebox[\textwidth]{From: K. Grant\phantom{3}\hfill
To: Dean A. Smith\hfill \phantom{From: K. Grant}3}
\end{fblock}

\noindent where ``3'' is the page number.  The title: ``The
performance of new graduates'' is bold.

This is accomplished by these commands following \Cmd{pagestyle\{fancy\}}
\footnote{Note that version 1 of fancyheadings used the
\Cmd{setlength} command to change the \texttt{\bs...rulewidth} parameters.}:
\CmdIndex{lhead}
\CmdIndex{rhead}
\CmdIndex{chead}
\CmdIndex{lfoot}
\CmdIndex{rfoot}
\CmdIndex{cfoot}
\CmdIndex{headrulewidth}
\CmdIndex{footrulewidth}
\begin{verbatim}
\lhead{}
\chead{}
\rhead{\textbf{The performance of new graduates}}
\lfoot{From: K. Grant}
\cfoot{To: Dean A. Smith}
\rfoot{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\end{verbatim}
(The \Cmd{thepage} macro displays the current page number.
\Cmd{textbf} puts it in bold face.)

This is now fine, except that the first page does not need
all these headers and footers.  To eliminate all but the
centered page number, issue the command

\CmdIndex{thispagestyle}
\begin{verbatim}
\thispagestyle{plain}
\end{verbatim}
after the
\Cmd{begin\{document\}}
and the
\CmdIndex{maketitle}
\Cmd{maketitle}
commands.

Alternatively, issue
\begin{verbatim}
\thispagestyle{empty}
\end{verbatim}
if you do not want any headers or footers.

In fact the standard \latex/ classes have the command \Cmd{maketitle}
defined in such a way that a \Cmd{thispagestyle\{plain\}} is automatically
issued. So if you \emph{do} want the fancy layout on a page containing
\Cmd{maketitle} you must issue a \Cmd{thispagestyle\{fancy\}} after the
\Cmd{maketitle}.

\section{An example of two-sided printing}\label{two-sided}

\TTindex{twoside}
Some document classes, such as \verb|book.cls|, print two-sided by default: the even
pages and the odd pages have different layouts; other document classes
use the \verb|twoside| option to print two-sided.

Now let us print the report two-sided.  Let the above page
layout be used for the odd (right-side) pages, and the
following for the even (left-side) pages:

\begin{fblock}

\noindent\makebox[\textwidth]{\textbf{The performance of new
graduates}\hfill}
\noindent\makebox[\textwidth]{\hrulefill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hfill page body\hfill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hrulefill}
\noindent\makebox[\textwidth]{4\phantom{To: Dean A. Smith}\hfill
 From: K. Grant\hfill \phantom{4}To: Dean A. Smith}

\end{fblock}
\noindent where ``4'' is the page number.

Here are the commands:

\begin{verbatim}
\fancyhead{} % clear all header fields
\fancyhead[RO,LE]{\textbf{The performance of new graduates}}
\fancyfoot{} % clear all footer fields
\fancyfoot[LE,RO]{\thepage}
\fancyfoot[LO,CE]{From: K. Grant}
\fancyfoot[CO,RE]{To: Dean A. Smith}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\end{verbatim}

\CmdIndex{fancyhead}
\CmdIndex{fancyfoot}
We use the more general commands \Cmd{fancyhead} and \Cmd{fancyfoot}.
These have an additional parameter between square brackets that specifies
for which pages and/or parts of the header/footer they apply. The first
\Cmd{fancyhead} command omits this parameter, and thus applies to all
header fields. In general this is only useful to get rid of the defaults or
a previous definition, as is done here. Similar the \Cmd{fancyfoot} command
without square brackets clears all footer fields. In this particular
example it could be omitted as all footer fields are specified.
The selectors that can be used
between the square brackets are given in figure~\ref{fig:sel}. Selectors can be combined so
\Cmd{fancyhead[LE,RO]\{text\}}
will define the field for both the left header on even pages and the right
header on odd pages. If you don't give an E or O the definition applies to
both. Similar for LRC. So the use of \Cmd{lhead} in the previous section
is just an abbreviation for \Cmd{fancyhead[L]}.
The selectors may be given as uppercase or lowercase letters.

\CmdIndex{fancyhf}
There is also a more general command \Cmd{fancyhf} that you can use to
combine the specifications for headers and footers. This allows additional
selectors H (header) and F (footer). In fact  \Cmd{fancyhead} and
\Cmd{fancyfoot} are just  \Cmd{fancyhf} with H and F prespecified.
\begin{figure}[tb]
  \begin{center}
    \leavevmode
    \begin{tabular}{|l|l|}
      \hline
      E & Even page         \\
      O & Odd page          \\
      \hline
      L & Left field        \\
      C & Center field      \\
      R & Right field       \\
      \hline
      H & Header            \\
      F & Footer            \\
      \hline
%%      T & float at Top      \\
%%      B & float at Bottom   \\
%%      F & Float page         \\
%%      \hline
    \end{tabular}
  \end{center}
  \caption{Selectors}
  \label{fig:sel}
\end{figure}

Again, you may
use  \Cmd{thispagestyle\{plain\}} for a simple page layout for
page~1.

\section{Redefining \texttt{plain} style}

Some \latex/ commands, like \Cmd{chapter}, use the \Cmd{thispagestyle}
command to automatically switch to the \texttt{plain} page style, thus
ignoring the page style currently in effect. 
To customize even such pages you must redefine the \texttt{plain}
pagestyle. As we indicated before you could do this by defining the
\Cmd{ps@plain} command, but \textsf{fancyhdr} gives you an easier way
with the \Cmd{fancypagestyle} command. This command can be used to
redefine existing pagestyles (like \texttt{plain}) or to define new ones,
e.g. if part of your document is to use a different pagestyle. This command
has two parameters: one is the name of the pagestyle to be defined, the
second consists of commands that change the headers and/or footers, i.e.
\verb|fancyhead| etc. Also allowed are changes to \Cmd{headrulewidth} and
\Cmd{footrulewidth}. 
  As an example, let us
redefine the \texttt{plain} style for the report in Section~\ref{two-sided} by
making the page number bold. 
\PSindex{plain}

\begin{verbatim}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[C]{\textbf{\thepage}} % except the center
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}
\end{verbatim}


\section{The default layout}\label{default}
Let us use the \verb|book.cls| documentclass and the default settings for
\textsf{fancyhdr}; so we only issue the commands

\begin{verbatim}
\usepackage{fancyhdr}
\pagestyle{fancy}
\end{verbatim}
and let \textsf{fancyhdr} take care of everything.  On the
pages where new chapters start, we get a centered page number in
the footer; there is no header, and there are no decorative lines.

On an even page, we get the layout:

\begin{fblock}
\noindent\makebox[\textwidth]{\textsl{1.2  EVALUATION}\hfill
 CHAPTER 1. INTRODUCTION}
\noindent\makebox[\textwidth]{\hrulefill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hfill page body\hfill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hrulefill}
\noindent\makebox[\textwidth]{\hfill4\hfill}
\end{fblock}

On an odd page, we get the layout:

\begin{fblock}
\noindent\makebox[\textwidth]{\textsl{CHAPTER 1. INTRODUCTION}\hfill
 1.2  EVALUATION}
\noindent\makebox[\textwidth]{\hrulefill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hfill page body\hfill}\\[\baselineskip]
\noindent\makebox[\textwidth]{\hrulefill}
\noindent\makebox[\textwidth]{\hfill
3\hfill }
\end{fblock}

\noindent where the header text is slanted uppercase.

This default layout is produced by the following commands:
\CmdIndex{rightmark}
\CmdIndex{leftmark}
\begin{verbatim}
\fancyhead[LE,RO]{\textsl{\rightmark}}
\fancyhead[LO,RE]{\textsl{\leftmark}}
\fancyfoot[C]{\thepage}
\end{verbatim}

The following settings are used for the decorative lines:

\begin{tabbing}
\CmdIndex{headrulewidth}
\noindent \Cmd{headrulewidth}\qquad \qquad \qquad \=0.4\=pt\\
\CmdIndex{footrulewidth}
\Cmd{footrulewidth}\>0\>pt
\end{tabbing}

The header text is turned into all uppercase in \verb|book.cls|.

\section{The scoop on \latex/'s marks}\label{sec:custom}

Usually, for documents of class \verb|book| and \verb|report|, you may
want to use chapter and section information in the headings (chapter only
for one-sided printing), and for documents of class \verb|article|,
section and subsection information (section only for one-sided
printing).  \latex/ uses a marker mechanism to remember the chapter and
section (section and subsection) information for a page; this is
discussed in detail in the
\latex/ \emph{Companion}, Section 4.3.1.

There are two ways you can use and change the higher- and lower-level
sectioning information available to you.  The macros:
\CmdIndex{rightmark}
\CmdIndex{leftmark}
\Cmd{leftmark}
(higher-level) and \Cmd{rightmark} (lower-level) contain the information
processed by \latex/, and you can use them directly as shown in 
Section~\ref{default}.

The \Cmd{leftmark} contains the Left argument of the \emph{Last}
\Cmd{markboth} on the page, the \Cmd{rightmark} contains the Right
argument of the \emph{fiRst} \Cmd{markboth} or the only argument of the
\emph{fiRst} \Cmd{markright} on the page. If no marks are present on a
page they are ``inherited'' from the previous page.

You can influence how chapter, section, and subsection
information (only two of them!) is displayed by redefining the
\CmdIndex{chaptermark}
\Cmd{chaptermark},
\CmdIndex{sectionmark}
\CmdIndex{subsectionmark}
\Cmd{sectionmark}, and \Cmd{subsectionmark} commands\footnote{There are
  similar commands for \texttt{paragraph} and \texttt{subparagraph} but
  they are seldom used.}. You must put the redefinition
after the first call of \Cmd{pagestyle\{fancy\}} as this
sets up the defaults.

Let us illustrate this with chapter info. It is made up of three parts:
\begin{itemize}
\CmdIndex{thechapter}
\item  the number (say, 2), displayed by the macro \Cmd{thechapter}
\item  the name (in English, Chapter), displayed by the macro
\CmdIndex{chaptername}
   \Cmd{chaptername}
\item  the title, contained in the  argument of
   \Cmd{chaptermark}.
\end{itemize}

Figure~\ref{fig:markers} shows some variants for ``Chapter 2.\ Do it now''
(the last example is appropriate in some non-English languages). The \%
signs at the end of the lines are to prevent unwanted space. Normally you
would continue the lines and remove these \% signs\footnote{the \texttt{\bs
    MakeUppercase} command is used in \LaTeXe{} to generate uppercase text,
  while in \LaTeX{} 2.09 \Cmd{uppercase} is used. The difference is
  that \Cmd{MakeUppercase} also deals with non-ASCII letters.
  Fancyhdr defines \Cmd{MakeUppercase} to be an alias for
  \Cmd{uppercase} if it isn't defined.}.

\begin{figure}[tb]
\CmdIndex{chaptermark}
\CmdIndex{uppercase}
\CmdIndex{MakeUppercase}
\setlength{\columnsep}{20pt}\small
\begin{multicols}{2}
\noindent Code:\\
\mbox{}\\
\verb|\renewcommand{\chaptermark}[1]{%|\\
\verb| \markboth{\chaptername|\\
\verb| \ \thechapter.\ #1}{}}|\\
\mbox{}\\
\verb|\renewcommand{\chaptermark}[1]{%|\\
\verb| \markboth{\MakeUppercase{%|\\
\verb| \chaptername}\ \thechapter.%|\\
\verb| \ #1}{}}|\\
\mbox{}\\
\verb|\renewcommand{\chaptermark}[1]{%|\\
\verb| \markboth{\MakeUppercase{%|\\
\verb| \chaptername\ \thechapter.%|\\
\verb| \ #1}}{}}|\\
\mbox{}\\
\verb|\renewcommand{\chaptermark}[1]{%|\\
\verb| \markboth{#1}{}}|\\
\mbox{}\\
\verb|\renewcommand{\chaptermark}[1]{%|\\
\verb| \markboth{\thechapter.\ #1}{}}|\\
\mbox{}\\
\verb|\renewcommand{\chaptermark}[1]{%|\\
\verb| \markboth{\thechapter.%|\\
\verb| \ \chaptername.\ #1}{}}|\\
Prints:\\
\mbox{}\\
Chapter 2.\ Do it now\\
\mbox{}\\
\mbox{}\\
\mbox{}\\
CHAPTER 2.\ Do it now\\
\mbox{}\\
\mbox{}\\
\mbox{}\\
\mbox{}\\
CHAPTER 2.\ DO IT NOW\\
\mbox{}\\
\mbox{}\\
\mbox{}\\
\mbox{}\\
Do it now\\
\mbox{}\\
\mbox{}\\
2.\ Do it now\\
\mbox{}\\
\mbox{}\\
2.\ Chapter.\ Do it now\\
\mbox{}\\
\end{multicols}
\caption{Marker variants}\label{fig:markers}
\end{figure}


For the lower-level sectioning information, do the same with
\Cmd{markright}.

So if ``Section 2.2.\ First steps'' is the current section,
then

\begin{verbatim}
\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\end{verbatim}
will give
   ``2.2.\ First steps''

Redefining the \Cmd{chaptermark} and \Cmd{sectionmark} commands may
not eliminate all uppercaseness. E.g.\ the bibliography will have a title
\CmdIndex{uppercase}
\index{BIBLIOGRAPHY}
of \textsc{bibliography} in the header, as the \Cmd{MakeUppercase} is
explicitly given in the definition of \Cmd{thebibliography}. Similar for
\index{INDEX}
\textsc{index} etc.\ If you don't want to redefine these commands, you can
use the \Cmd{nouppercase} command that \textsf{fancyhdr} makes available in the header
and footer fields. Note that this may screw other things, like uppercase
roman numerals in your headers, so it should be used with care. Essentially
this command typesets its argument in an environment where
\Cmd{MakeUppercase} and \Cmd{uppercase} are changed into do-nothing operations.


\begin{verbatim}
\lhead{\nouppercase{\rightmark}}
\rhead{\nouppercase{\leftmark}}
\end{verbatim}


It should be noted that the \latex/ marking mechanism works fine with
chapters (which always start on a new page) and sections (which are
reasonably long).  It does not work quite as well with short sections and
subsections.  This is a problem with \latex/, not with
\textsf{fancyhdr}.

As an example let's take a page layout where the leftmarks are generated by
the sections and the rightmarks by the subsections (as is default in the
\texttt{article} class). Take a page with some short sections, e.g. 

\begin{samepage}
\noindent Section 1.\\
subsection 1.1\\
subsection 1.2\\
Section 2.  
\end{samepage}

As the leftmark contains the \emph{last} mark of the page it will be
``Section 2.'', and the rightmark will be ``subsection 1.1'' as it will be
the \emph{first} mark of the page. So the page header info will combine 
section 2 with subsection 1.1 which isn't very nice.
The best you can do in these cases is use only the \Cmd{rightmark}s and
redefine \Cmd{sectionmark} accordingly. A \latex/ command
\CmdIndex{firstleftmark}
\Cmd{firstleftmark} would also be a nice addition (see the 
\texttt{extramarks} package in section~\ref{sec:xmarks}).

Another problem with the marks in the standard \latex/ classes is that the
higher level sectioning commands (e.g. \Cmd{chapter}) call
\Cmd{markboth} with an empty right argument. This means that on the first
page of a chapter (or a section in article style) the \Cmd{rightmark}
will be empty. If this is a problem you must manually insert extra
\Cmd{markright} commands or redefine the \Cmd{chaptermark}
(\Cmd{sectionmark}) commands to issue a \Cmd{markboth} command with
two decent parameters.

As a final remark you should also note that the \verb|*| forms of the
\Cmd{chapter} etc.\ commands do \emph{not} call the mark commands. So if
you want your preface to set the header info but not be numbered nor be put in
the table of contents, you must issue the \Cmd{markboth} command
yourself, e.g.

\begin{verbatim}
\chapter*{Preface\markboth{Preface}{}}
\end{verbatim}

Entering the \Cmd{markboth} command inside the \Cmd{chapter*} insures
that the mark will not be separated from the title by a page break. Of
course with \Cmd{chapter*} this wouldn't be  a problem if you put the mark
command after the chapter title, as the \Cmd{chapter*} command starts at a
new page. However with a \Cmd{section*} it could be dangerous to say:

\begin{verbatim}
\section*{Preface}
\markboth{Preface}{}
\end{verbatim}
as a page break may occur between the two commands.

\section{Dictionary style headers}

\index{dictionary}
\index{concordance}
Dictionaries and concordances usually have a header containing the first
word defined on the page or both the first and the last words. This can
easily be accomplished with \textsf{fancyhdr} and \latex/'s
\texttt{mark} mechanism. Of course if you use the marks for dictionary
style headers, you cannot use them for chapter and section information, so
if there are also chapters and sections present, you must redefine the
\Cmd{chaptermark} and \Cmd{sectionmark} to make them harmless:

\begin{verbatim}
\renewcommand{\chaptermark}[1]{}
\renewcommand{\sectionmark}[1]{}
\end{verbatim}

Now you do a \Cmd{markboth\{\#1\}\{\#1\}} for each dictionary or concordance
entry \verb|#1| and use \Cmd{rightmark} for the first entry defined on
the page and \Cmd{leftmark} for the last one.

If you want to use a header entry of the form \textsf{firstword--lastword}
it would be nice if this would be reduced to just the form
\textsf{firstword} if both are the same. This could happen if there is just
one entry on the page. In this case a test must be made to check if the
marks are the same.  However, \tex/'s marks are strange beasts, which
cannot be compared out of the box with the plain \tex/ \Cmd{if} commands.
\TTindex{ifthen}
Fortunately the \texttt{ifthen} package works well:

\begin{verbatim}
\newcommand{\mymarks}{
  \ifthenelse{\equal{\leftmark}{\rightmark}}
    {\rightmark} % if equal
    {\rightmark--\leftmark}} % if not equal
\fancyhead[LE,RO]{\mymarks}
\fancyhead[LO,RE]{\thepage}
\end{verbatim}

\section{Fancy layouts}

\index{multi-line}
You can make a multi-line field with the \Cmd{\bs} command.  It is also
possible to put extra space in a field with the \Cmd{vspace} command.
Note that if you do this you will probably have to increase the height of
\CmdIndex{headheight}
\CmdIndex{footskip}
the header (\Cmd{headheight}) and/or of the footer (\Cmd{footskip}),
\index{Overfull \verb+\vbox+ \ldots}
otherwise you may get error messages ``Overfull \Cmd{vbox} \ldots has
occurred while \Cmd{output} is active''%
\footnote{If you use \texttt{11pt} or \texttt{12pt} you will probably also
  have to do this, because \LaTeX's defaults are quite small}.
See Section 4.1 of the \latex/ \emph{Companion} for detail.

For instance, the following code will place  the section title and the
subsection title of an article in two lines in the upper right hand
corner:

\begin{verbatim}
\documentclass{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\addtolength{\headheight}{\baselineskip}
\renewcommand{\sectionmark}[1]{\markboth{#1}{}}
\renewcommand{\subsectionmark}[1]{\markright{#1}}
\rhead{\leftmark\\\rightmark}
\end{verbatim}

You can also customize the decorative lines.  You can make the decorative
line in the header quite thick with

\CmdIndex{headrulewidth}
\begin{verbatim}
\renewcommand{\headrulewidth}{0.6pt}
\end{verbatim}
or you can make the decorative line in the footer disappear with
\CmdIndex{footrulewidth}
\begin{verbatim}
\renewcommand{\footrulewidth}{0pt}
\end{verbatim}

The decorative lines, themselves, are defined in the two macros
\Cmd{headrule} and \Cmd{footrule}.  For instance,
if you want a dotted line rather than a solid line in the header,
redefine the command \Cmd{headrule}:

\begin{verbatim}
\renewcommand{\headrule}{\vbox to 0pt{\hbox
    to\headwidth{\dotfill}\vss}}
\end{verbatim}

As an alternative to changing \Cmd{headrulewidth} to 0 to have the rule disappear, you can also make it empty with
\begin{verbatim}
\renewcommand{\headrule}{}
\end{verbatim}
Visually this make no difference, but it is more difficult to restore it later to its default value.

Finally, let us make a real `decorative' line\footnote{Based upon an idea by Wayne Chan.}.
\begin{verbatim}
\usepackage{fourier-orns}
...
\renewcommand\headrule{\hrulefill
\raisebox{-2.1pt}[10pt][10pt]{\quad\decofourleft\decotwo\decofourright\quad}\hrulefill}
\end{verbatim}
This gives us the following headrule:

\noindent\makebox[\textwidth]{\hrulefill \raisebox{-2.1pt}[10pt][10pt]{\quad\decofourleft\decotwo\decofourright\quad}\hrulefill}

\CmdIndex{footruleskip}
There is one additional parameter that you can set: \Cmd{footruleskip}. It
defines the distance between the decorative line in the footer and the top
of the footer text line. By default it is set to 30\% of the normal line
distance. You may want to adjust it if you use unusally large or small
fonts in the footer. Change it with \Cmd{renewcommand}.

\section{Two book examples}
The following definitions give an approximation of the style
used in L. Lamport's \latex/ book.

Lamport's header overhangs the outside margin.  This is done as follows.

The width of headers and footers is \Cmd{headwidth}, which by default
equals the width of the text: \Cmd{textwidth}. You can make the width
\CmdIndex{headwidth}
wider (or narrower) by redefining \Cmd{headwidth} with the
\Cmd{setlength} and \Cmd{addtolength} commands.
To overhang the outside margin where the marginal notes are
\CmdIndex{marginparsep}
\CmdIndex{marginparwidth}
printed, add both \Cmd{marginparsep} and \Cmd{marginparwidth} to
\Cmd{headwidth} with the commands:

\begin{verbatim}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\end{verbatim}

\begin{flushleft}
You must issue these commands \emph{after} the first
\Cmd{pagestyle\{fancy\}} command as this
will establish the default for \Cmd{headwidth}\footnote{In version 2 of
  \textsf{fancyhdr} it is usually safe to do it before, but it is still
  advised to do after.}.
\end{flushleft}

And now a complete definition of Lamport's book style:

\begin{verbatim}
\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\addtolength{\headwidth}{\marginparsep}
\addtolength{\headwidth}{\marginparwidth}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}
\fancyhf{}
\fancyhead[LE,RO]{\textbf{\thepage}}
\fancyhead[LO]{\textbf{\rightmark}}
\fancyhead[RE]{\textbf{\leftmark}}
\fancypagestyle{plain}{%
   \fancyhead{} % get rid of headers
   \renewcommand{\headrulewidth}{0pt} % and the line
}
\end{verbatim}
\PSindex{plain}

Notice that the \Cmd{chaptermark} and \Cmd{sectionmark} commands have
been redefined to eliminate the chapter numbers and the uppercaseness.

For more control about the horizontal position of the headers and/or footers, \textsf{fancyhdr} has additional commands to specify the offset of the header and/or footer elements. Use \Cmd{fancyhfoffset[place]\{length\}} 
\CmdIndex{fancyhfoffset} 
to offset one or more elements. The \texttt{place} parameter is like the optional parameter of \Cmd{fancyhf}, like \texttt{L R E O}, except that \texttt{C} cannot be used. It specifies for which elements the offset should be applied. The \texttt{length} parameter specifies the actual offset. Positive values move the element outward (into the margin), negative values inward. There are also specialised commands \Cmd{fancyheadoffset} and \Cmd{fancyfootoffset}, which have the \texttt{H} and \texttt{F} parameter pre-applied, respectively.
\CmdIndex{fancyheadoffset} 
\CmdIndex{fancyfootoffset} 

When you use these commands, \latex/ will recalculate \Cmd{headwidth}, based on the given parameters.

So the above example could also have been done with (N.B. You can only use such an expression as a length parameter if the \textsf{calc} package is used):

\begin{verbatim}
\fancyheadoffset[LE,RO]{\marginparsep+\marginparwidth}
\end{verbatim}

For the second example, we take the \amslatex/ book.% \cite{gG93B}.
% George Gratzer, Math into LaTeX, An Introduction to LaTeX and AMS-LaTeX,
% Birkhauser Boston, ISBN 0-8176-3805-9

Chapter pages have no headers or footers.  So we declare

\begin{verbatim}
\thispagestyle{empty}
\end{verbatim}
for every chapter page, and we do not need to redefine plain.

Chapter and section titles appear in the form: 2.\ DO IT NOW, so we have
to redefine \Cmd{chaptermark} and \Cmd{sectionmark} as follows (see
Section~\ref{sec:custom}):

\begin{verbatim}
\renewcommand{\chaptermark}[1]%
   {\markboth{\MakeUppercase{\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]%
   {\markright{\MakeUppercase{\thesection.\ #1}}}
\end{verbatim}

In an even-header, the page number is printed as the LeftHeader and
the chapter info as the RightHeader; in an odd-header, the section info
is printed as the LeftHeader and the page number as the RightHeader.  The
CenteredHeaders are empty.  There are no footers.

There is a decorative line in the header.  It is 0.5pt wide, so we need
the commands:

\begin{verbatim}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\end{verbatim}

The font used in the headers is 9 pt bold Helvetica.  The \PSNFSS\ system
by Sebastian Rahtz uses the short (Karl Berry) name \verb|phv| for
Helvetica, so this font is selected with the commands:
\begin{verbatim}
\fontfamily{phv}\fontseries{b}\fontsize{9}{11}\selectfont
\end{verbatim}
(See Sections 7.6.1 and 11.9.1 of the \latex/ \emph{Companion}.)
Let us define a shorthand for this:
\begin{verbatim}
\newcommand{\helv}{%
   \fontfamily{phv}\fontseries{b}\fontsize{9}{11}\selectfont}
\end{verbatim}

Now we are ready for the page layout:

\begin{verbatim}
\documentclass{book}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]%
   {\markboth{\MakeUppercase{\thechapter.\ #1}}{}}
\renewcommand{\sectionmark}[1]%
   {\markright{\MakeUppercase{\thesection.\ #1}}}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0pt}
\newcommand{\helv}{%
   \fontfamily{phv}\fontseries{b}\fontsize{9}{11}\selectfont}
\fancyhf{}
\fancyhead[LE,RO]{\helv \thepage}
\fancyhead[LO]{\helv \rightmark}
\fancyhead[RE]{\helv \leftmark}
\end{verbatim}


\section{Special page layout for float pages}
\label{sec:float}

\index{float page}
Some people want to have a special layout for float pages (pages only
containing floats). As these pages
are generated autonomically by \latex/, the user doesn't have any control
over them. There is no \Cmd{thispagestyle} for float pages and any change
of the page style will at least also affect the page before the float page.
With \textsf{fancyhdr}, however, you can specify in each of
the header- or footer fields

\Cmd{iffloatpage\{}value for float page\verb|}{|value for other pages\verb|}|

You can even use this to get rid of the decorative line on float pages only
by defining:

\begin{verbatim}
\renewcommand{\headrulewidth}{\iffloatpage{0pt}{0.4pt}}
\end{verbatim}

Sometimes you may want to change the layout also for pages that contain a
float on the top of the page, a float on the bottom of the page or a footnote on the bottom of the page.

\textsf{fancyhdr} gives you the commands \Cmd{iftopfloat}, \Cmd{ifbotfloat} and \Cmd{iffootnote}
similar to \Cmd{iffloatpage}.

Note: Marks in floats will not be visible in \latex/'s output routine, so
it is not useful to put marks in floats. So there is currently no way to
let a float (e.g.\ a figure caption) influence the page header or footer.

\section{Those blank pages}
\label{sec:blank}

In the \texttt{book} class when the \texttt{openany} option is not given or
in the \texttt{report} class when the \texttt{openright} option is given,
chapters start at odd-numbered pages, half of the time causing a blank page
to be inserted. Some people prefer this page to be completely empty, i.e.\ 
without headers and footers. This cannot be done with \Cmd{thispagestyle}
as this command would have to be issued on the \emph{previous} page. There
is, however, no magic necessary to get this done:

\PSindex{empty}
\CmdIndex{clearpage}
\CmdIndex{cleardoublepage}
\begin{verbatim}
\clearpage{\pagestyle{empty}\cleardoublepage}
\end{verbatim}

As the \Cmd{pagestyle\{empty\}} is enclosed in a group it only affects the
page that may be generated by the \Cmd{cleardoublepage}.  You can of
course put the above in a private command. If you want to have this done
automatically at each chapter start or when you want some other text on the
page then you must redefine the \Cmd{cleardoublepage} command.
\index{blank page}
\begin{verbatim}
\makeatletter
\def\cleardoublepage{\clearpage\if@twoside \ifodd\c@page\else
  \hbox{}
  \vspace*{\fill}
  \begin{center}
    This page intentionally contains only this sentence.
  \end{center}
  \vspace{\fill}
  \thispagestyle{empty}
  \newpage
  \if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\end{verbatim}

\section{\textsf{N} of \textsf{M} style page numbers}
\label{sec:nofm}

Some document writers prefer the pages to be numbered as \textsf{n} of
\textsf{m} where \textsf{m} is the number of pages in the document. There is a package \texttt{lastpage}
available which you can use with \textsf{fancyhdr} as follows:

\begin{verbatim}
\usepackage{lastpage}
...
\cfoot{\thepage\ of \pageref{LastPage}}
\end{verbatim}

The value of the \texttt{LastPage} label can be used to
make different headers or footers on the last page of a document. E.g.\ if
you want the footer of every odd page, except if it is the last one, to
contain the text ``please turn over'', this can be done as
follows:

\begin{verbatim}
\usepackage{lastpage}
\usepackage{ifthen}
...
\rfoot{\ifthenelse{\isodd{\value{page}} \and \not
    \value{page}=\pageref{LastPage}{please turn over}{}}
\end{verbatim}

\section{Chapter or section related page numbers}

In technical documentation very often page numbers are used of the form
2-10 where the first number is the chapter number and the second is the
pagenumber relative to the chapter. Sometimes section is used rather than
chapter. The package \textsf{chappg} can be used to get this format. 

Basically this package redefines \Cmd{thepage} as 
\Cmd{thechapter}\Cmd{chappgsep}\Cmd{arabic\{page\}}, where \Cmd{chappgsep} by default is ``-''. If you want do use a different separator, you must redefine \Cmd{chappgsep}, for example to use an en-dash:

\begin{verbatim}
\renewcommand{\chappgsep}{--}
\end{verbatim}

To use a different prefix, for example the section number, use the \Cmd{pagenumbering\{bychapter\}} command with an optional argument specifying the prefix.
\CmdIndex{pagenumbering}

\begin{verbatim}
\pagenumbering[\thesection]{bychapter}
\end{verbatim}

What the package also does is reset the page number to 1 at the beginning
of each chapter.

There is a caveat when you have appendixes in your document. Before the
\Cmd{appendix} command you should give a \Cmd{clearpage} or
\Cmd{cleardoublepage}. See the \textsf{chappg} documentation for
details.

There is a fundamental difference between the page numbering of the style
``\emph{m} of \emph{n}'' as described in the previous section and the
current one. The \emph{m} of \emph{n} style is only used in the page header
or footer, but not in the table of contents, index, or references like
``\emph{See page \emph{xx}}''. Therefore it does not change the command
\Cmd{thepage}. The page numbering style ``2-10'', however should be used
in all references to the page number, therefore it must be done by redefining
\Cmd{thepage}. 


\section{When to change the headers and footers?}
\label{sec:change}

Sometimes you want to change the header or footer layout in the course of a
document. Some of these changes can be accomplished by using the mark
mechanism as may be seen in section~\ref{sec:custom} and \ref{sec:xmarks}.
However, sometimes we want a more drastic change, e.g to change the page
numbering from roman to arabic (with \Cmd{pagenumbering}), to change one of
\index{page style!changes}
the \textsf{fancyhdr} fields or to change to another page style.
Sometimes you may be surprised to find the change to occur too early. In
general the above mentioned changes take effect immediately, i.e.\ on the
page that is currently being built. If you want the change to take effect
at the next page you must make sure that the current page is finished. In
\CmdIndex{clearpage}
most cases this can be done by issuing a \Cmd{clearpage} command before
any of the above mentioned changes. If this is not possible you can use the 
\TTindex{afterpage.sty}
\texttt{afterpage} package with:\\
\Cmd{afterpage\{}\Cmd{lhead\{new value\}\}} or
\CmdIndex{pagenumbering}
\Cmd{afterpage\{}\Cmd{pagenumbering\{roman\}\}}. You cannot use \Cmd{afterpage}
to change the \Cmd{pagestyle} as the commands issued by \Cmd{afterpage}
are local in a group, and the \Cmd{pagestyle} command makes only local
changes. The \Cmd{pagenumbering} and the \textsf{fancyhdr} commands
make global changes so they will work, as will the \Cmd{thispagestyle}
command. 

It should be noted that although the \textsf{fancyhdr} commands like
\Cmd{fancyhead} take effect immediately, this does not mean that any
``variables'' used in these commands get the value they have at the place
where these commands are given. E.g.\ if \Cmd{fancyfoot[C]\{}\Cmd{thepage\}} is given
the page number that will be inserted in the footer is not the page number
of the page where this command is given, but rather the page number of
the actual page where the footer is constructed. Of course for the page
number this is what you expect, but it is also true for other commands.

So if you have a book where each chapter is written by a different author
and you want the name of the author in the lower left-hand corner you can
use the following commands:

\begin{verbatim}
\newcommand{\TheAuthor}{}
\newcommand{\Author}[1]{\renewcommand{\TheAuthor}{#1}}
\lfoot{\TheAuthor}
\end{verbatim}

\noindent and start each chapter with the command 
\Cmd{Author\{Real Name\}}.
 If however, the author name would be changed before a page is
completed the wrong author could come in the footer. This would be the case
if you gave the above command \emph{before} the \Cmd{chapter} command
rather than after it. 
Another source of problems is the fact that \tex/'s output routine processes
commands ahead, so it may already have processed some commands that produce
text that will appear on the next page. See the next section for an example.

\section{Headers and footers induced by the text}
\label{sec:xmarks}

We have seen how we can use \LaTeX's marks to get information from the
document contents to the headers and footers. The marks mechanism is the
only reliable mechanism that you can use to get changing information to the
headers or footers. This is because \latex/ may be processing your document
ahead before deciding to break the page. 

Sometimes the two marks that \latex/ offers are not enough. An example is
the following:
\begin{quote}
 If a solution to an exercise goes across a page break, then I would like
 to have ``(Continued on next page\ldots)'' at the bottom of the
\index{Continued\ldots}
 first page and ``(Continued\ldots)'' at the top in the margin of the next page.
\end{quote}

You cannot use \latex/'s mark mechanisms for this if you also want to use
chapter and section information.

The \textsf{extramarks} package gives you
two extra marks that can be used in this situation.
Here is a way to use this package:

\begin{verbatim}
\usepackage{extramarks}
...
\pagestyle{fancy}
\lhead{\firstxmark}
\rfoot{\lastxmark}
...
\extramarks{}{Continued on next page\ldots}
Some text that may or may not cross a page boundary...
\extramarks{Continued\ldots}{}
\end{verbatim}

\CmdIndex{extramarks}
Note that the \Cmd{extramarks} command must be close to the text, i.e no
empty lines (paragraph boundaries) should intervene. Otherwise the page may
be broken at that boundary and the extramarks would come on the wrong page.

There are two new marks that can be used in the page layout with this
package: If commands of the form
\verb|\extramarks{|$m_1$\verb|}{|$m_2$\verb|}| are given
\CmdIndex{firstxmark}
\CmdIndex{lastxmark}
\Cmd{firstxmark} gives you the first $m_1$ value and
\Cmd{lastxmark} gives you the last $m_2$ value
of the current page.

In case you want the last  $m_1$ value or the first  $m_2$ value, you can use the \Cmd{lastleftxmark} or \Cmd{firstrightxmark}, respectively. For symmetry reasons there are also commands \Cmd{firstleftxmark} (=\Cmd{firstxmark}), \Cmd{lastrightxmark} (=\Cmd{lastxmark}), \Cmd{topleftxmark} (=\Cmd{topxmark}) and \Cmd{toprightxmark}. The top-marks are basically the last-marks of the previous page.
\CmdIndex{lastleftxmark}
\CmdIndex{firstrightxmark}
\CmdIndex{firstleftxmark}
\CmdIndex{lastrightxmark}
\CmdIndex{topleftxmark}
\CmdIndex{toprightxmark}

The package also gives you the \Cmd{firstleftmark} and \Cmd{lastrightmark}
commands that complement the standard \latex/ marks.
\CmdIndex{firstleftmark}
\CmdIndex{lastrightmark}

To stress the point that marks are the correct way to do this, let me
give you a ``solution'' that will not work\footnote{Actually there is
  another way but it requires two \latex/ passes: you can put \Cmd{label}
  commands before and after the text and compare the \Cmd{pageref}s.}:

\begin{verbatim}
\lhead{Continued}
\rfoot{Continued on next page\ldots}
Some text that may or may not cross a page boundary...
\lhead{}
\rfoot{}
\end{verbatim}

You may be tempted to think that the first \Cmd{lhead} and \Cmd{rfoot}
will be in effect when \tex/ breaks the page in the middle of the text,
and the last ones when the page breaks after the text. This is not true as
the whole paragraph (including the last definitions) will be processed
\index{page break}
before \tex/ considers the page break, so at the time of the page break the
last definitions are effective, whether the page break occurs inside the text
or outside of it. Putting a paragraph boundary between the
text and the last definitions will not work either, because you don't want
the first definitions to be in effect when \tex/ decides to break the page
exactly at this boundary. Actually the marks mechanism was invented to get
rid of these kinds of problems.

In the above example the text ``Continued'' appears in the page header. It
\index{margin}
may be nicer to put it in the  margin. This can be easily
accomplished by positioning it at a fixed place relative to the page header.
In plain \tex/ you would use a concoction of \Cmd{hbox to 0pt},
\Cmd{vbox to 0pt}, \Cmd{hskip},\Cmd{vskip}, \Cmd{hss} and
\Cmd{vss} but fortunately 
\latex/'s \texttt{picture} environment gives a much cleaner way to do this.
In order not to disturb the normal header layout we put the text in a zero-sized
\texttt{picture}. Generally this is the best way to position things on fixed
places on the page. You can then also use the normal headings. See also
section~\ref{sec:thumb} for another example of 
this technique.

\TTindex{picture}
\begin{verbatim}
\lhead{\setlength{\unitlength}{\baselineskip}%
\begin{picture}(0,0)
  \put(-2,-3){\makebox(0,0)[r]{\firstxmark}}
  \end{picture}\leftmark}
\end{verbatim}

This solution can of course also be used for the footer. Make sure you put the
\texttt{picture} as the first thing in left-handside entries and last in right-handside
ones.

Finally you may want to put ``(Continued\ldots)'' in the \emph{text}
rather than in the header or the margin. Then you have to use the
\TTindex{afterpage.sty}
\texttt{afterpage} package. We also decide to make a separate
environment for it.

\begin{verbatim}
\newenvironment{continued}{\par
  \extramarks{}{Continued on next page\ldots}
  \afterpage{\noindent\firstxmark\vspace{1ex}}
  }{\extramarks{(Continued\ldots)}{}\par}
\end{verbatim}

It is a bit dangerous to use \Cmd{firstxmark} outside the page layout
routine, but apparently with \Cmd{afterpage} this works. If you would
need the information further on in the page you must remember the state of
the marks in your own variable. You can set this in one of the
\textsf{fancyhdr} fields. For example if you want to add something
\emph{after} the broken piece of text you can use the following:

\begin{verbatim}
\newcommand{\mysaved}{}

\newenvironment{continued}{\par
  \extramarks{}{Continued on next page\ldots}
  }{\extramarks{(Continued\ldots)}{}\par\vspace{1ex}\mysaved}
\lhead{\leftmark}
\chead{\ifthenelse{\equal{\lastxmark}{}}
  {\gdef\mysaved{}}
  {\gdef\mysaved{\noindent[Continued from previous page]}}}
\end{verbatim}

If you want to include one of the marks or other varying information in the
saved text, you must use \Cmd{xdef} rather than \Cmd{gdef}.


\section{A movie}
\label{sec:movie}

\index{movie}
\TTindex{picture}
If you put at each page on the same place a picture that slightly changes
from page to page you can get a movie-like effect by flipping through the
pages. You can create such a movie easily with fancyhdr. For
simplicity we assume that each picture is in a postscript (EPS) file called
\texttt{pic}$\langle n\rangle$.\texttt{ps} where $\langle n\rangle$ is the page number and that we use
the \texttt{graphics} or  \texttt{graphicx} package\footnote{If you use an older version of
  \LaTeX{} you could use the \texttt{epsf} or \texttt{epsfig} package.}. 
\TTindex{graphics}
\TTindex{graphicx}
\TTindex{epsf}
\TTindex{epsfig}
To put the movie in the  righthandside bottom corner the following will work:

\begin{verbatim}
\rfoot{\setlength{\unitlength}{1mm}
  \begin{picture}(0,0)
    \put(5,0){\includegraphics{pic\thepage.ps}}
  \end{picture}}
\end{verbatim}

Notice that the \Cmd{unitlength} parameter should
be set locally in the fancyhdr field in order to avoid unwanted
interference with its value in the text.

\section{Thumb-indexes}
\label{sec:thumb}

\index{bible}
Some railroad guides and expensive bibles have so called
\index{thumb-index}
\emph{thumb-indexes}, i.e.\ there are marks on the sides of the pages that
indicate where the chapters are. You can create these by printing black
blobs in the margin of the pages. The vertical position should be
determined by the chapter number or some other counter. As the position is
independent of the contents of the page, we print these blobs as part of
the header in a zero-sized \texttt{picture} as described in the previous
section.

Of course we have to take care of two-sided printing, and we may want to
have an index page with all the blobs in the correct position. The solution
requires some hand-tuning to get the blobs nicely spaced out vertically.
For the application that I had there were 12 sections, so I made the blobs
18 mm apart, i.e. 9~mm blob separated by 9~mm whitespace. In order to avoid
calculations they are set in a \texttt{picture} environment with the
\Cmd{unitlength} set to 18~mm. Page numbers are set in the headers at the
outer sides, and the blobs are attached to these. In this example the
section numbers are used to position the blobs, but you can replace this
with any numeric value. 
See figure~\ref{fig:overview} for the resulting
overview page and figure~\ref{fig:thumb} for the code.

\begin{figure}[htbp]
\setlength{\unitlength}{9mm}
\newcommand{\blob}{\rule[-.2\unitlength]{1\unitlength}{.5\unitlength}}
\newcounter{line}
\newcommand{\secname}[1]{\addtocounter{line}{1}%
  \put(1,-\value{line}){\blob}
  \put(-7.5,-\value{line}){\arabic{line}}
  \put(-7,-\value{line}){#1}}

\newcommand{\overview}{1
  \begin{picture}(0,0)
    \secname{Introduction}
    \secname{The first year}
    \secname{Specialisation}
  \end{picture}}
 
  \begin{center}
    \leavevmode
    \begin{picture}(11.3,5)
      \put(0,0){\framebox(11.3,5)[tr]{}}
      \put(9,4.5){\overview}
    \end{picture}
  \end{center}
  \caption{Thumb-index overview page}
  \label{fig:overview}
\end{figure}
\begin{figure}[hp]\small
\begin{verbatim}
\setlength{\unitlength}{18mm}
\newcommand{\blob}{\rule[-.2\unitlength]{2\unitlength}{.5\unitlength}}

\newcommand\rblob{\thepage
  \begin{picture}(0,0)
    \put(1,-\value{section}){\blob}
  \end{picture}}

\newcommand\lblob{%
  \begin{picture}(0,0)
    \put(-3,-\value{section}){\blob}
  \end{picture}%
  \thepage}

\pagestyle{fancy}
\cfoot{}

\newcounter{line}
\newcommand{\secname}[1]{\addtocounter{line}{1}%
  \put(1,-\value{line}){\blob}
  \put(-7.5,-\value{line}){\Large \arabic{line}}
  \put(-7,-\value{line}){\Large #1}}

\newcommand{\overview}{\thepage
  \begin{picture}(0,0)
    \secname{Introduction}
    \secname{The first year}
    \secname{Specialisation}
...etc...
  \end{picture}}

\begin{document}
\fancyhead[R]{\overview}\mbox{}\newpage % This produces the overview page
\fancyhead[R]{} % Front matter may follow here
\clearpage
\fancyhead[RE]{\rightmark}
\fancyhead[RO]{\rblob}
\fancyhead[LE]{\lblob}
\fancyhead[LO]{{\leftmark}
...
\end{verbatim}
  \caption{Thumb-index code}
  \label{fig:thumb}
\end{figure}

\section{Float placement}

Floats are page elements that float with respect to the rest of the
document. Standard floats are tables and figures, but with the
\textsf{float} package you can easily make new ones, like algorithms. Most
of the time floats work satisfactory, but sometimes \LaTeX{} seems too
stubborn to do what you want. This section describes how you can influence
\LaTeX{} so that it will do most of the time what you want. There might,
however be some pathological cases where it is impossible to convince
\LaTeX{} to do things your way. In the following we will use figures as an
example but everything applies to other floats as well.

The most encountered problems with floats are:
\begin{enumerate}
\item You want a float at a certain position in the text, but \LaTeX{}
  moves it, usually to the next page.
\item From a certain point, \LaTeX{} moves all your floats to the end of
  the document or the end of a chapter.
\item \LaTeX{} complains about ``Too many floats''.
\end{enumerate}

In the first two cases you must first check if you have given the correct
``placement'' parameter to you float, e.g. \Cmd{begin\{figure\}[htp]}
specifies that your figure may be placed either: Here (i.e. in the text
position where the command is given), on the Top of a page (which may be
the page where you put the command), or on a separate Page of floats. You
could also have specified ``b'' for Bottom of the page. The order of the
letters is insignificant, you cannot force \LaTeX{} to try Bottom first
and then Top by specifying \texttt{[bt]}.

If \LaTeX{} doesn't put the float at the place where you expected it, it is
usually caused by the following:
\begin{enumerate}
\item The float didn't fit on the page. In this case it has to move to the
  next page or even further. If you didn't specify either \texttt{[t]} or
  \texttt{[b]} in the position parameter, \latex/ must save it until it has
  enough for a page of floats. So don't specify only \texttt{[h]}. If you
  want to give \latex/ a chance to put the float on a page of floats, you
  must also specify ``p''.
\item The placement would violate the constraints imposed by \latex/'s
  float placement parameters. This is one of the most occurring causes and
  it can easily be corrected by changing the parameters. Here is a list of
  them:
\end{enumerate}
\begin{center}
\CmdIndex{topfraction}
\CmdIndex{bottomfraction}
\CmdIndex{textfraction}
\CmdIndex{floatpagefraction}
\TTindex{topnumber}
\TTindex{bottomnumber}
\TTindex{totalnumber}
  \begin{tabular}{>{\tt}llc}
    \hline
    \multicolumn{3}{c}{Counters -- change with \Cmd{setcounter}}\\
    \hline
    topnumber & max. number of floats at top of page & 2 \\
    bottomnumber & max. number of floats at bottom of page & 1 \\
    totalnumber &  max. number of floats on a page & 3\\
    \hline
    \multicolumn{3}{c}{Other -- change with \Cmd{renewcommand}}\\
    \hline
    \bs topfraction & max fraction of page for floats at top & 0.7 \\
    \bs bottomfraction & max fraction of page for floats at bottom & 0.3 \\
    \bs textfraction & min fraction of page for text & 0.2 \\
    \bs floatpagefraction & min fraction of floatpage that should have
    floats  & 0.5 \\ 
    \hline
  \end{tabular}
\end{center}

There are also some others for double column floats in two-column documents.

The values in the righthand column are the defaults for the standard
\latex/ classes. Other classes could use different defaults. As you see
with the default values a float will not be put in the bottom of a page if
its height is more than 30\% of the page height. So if you specify [hb] for
a float which is taller it has to move to a float page. But if it is less
than 50\% of the page height it will have to wait until some more floats
are given before a float page can be filled to satisfy the
\Cmd{floatpagefraction} parameter. If you have this kind of behaviour you
can easily adapt the parameters, e.g. with:
\begin{verbatim}
\renewcommand{\textfraction}{0.05}
\renewcommand{\topfraction}{0.95}
\renewcommand{\bottomfraction}{0.95}
\renewcommand{\floatpagefraction}{0.35}
\setcounter{totalnumber}{5}
\end{verbatim}
You may want to be careful not to make \Cmd{floatpagefraction} too small,
otherwise you may get too many small floatpages.

You can force \latex/ to ignore most of the parameters for one specific float
occurrence by
including an exclamation mark (!) in the placement parameters, e.g.
\begin{verbatim}
\begin{figure}[!htb]
\end{verbatim}

Floats which contain a ``\texttt{t}'' in the position parameter could be
placed before the place where they are referenced (but on the same page).
This is normal behaviour for \latex/ but some people just don't like it.
There are a number of ways to prevent this: 
\begin{enumerate}
\item Of course deleting the ``\texttt{t}'' will help, but in general this is
  undesirable, as you may want the float to be placed at the top of the
  next page.
\item use the \texttt{flafter} package which causes floats never to be
  placed ``backwards''.
\item use the command \Cmd{suppressfloats[t]}.  This
  command will cause floats for the top position \emph{on this page} to be
  moved to the next page. This can also be done with \texttt{[b]} or
  without parameter for all floats on this page.
\end{enumerate}

If in spite of all your attempts \latex/ still moves your floats to the end
of the document or the end of a chapter, you can insert a \Cmd{clearpage}
command. This will start a new page and insert all pending floats before
continueing. If it is undesirable to have a pagebreak you can use the
\textsf{afterpage} package and the following command:
\begin{verbatim}
\afterpage{clearpage}
\end{verbatim}

This will wait until the current page is finished and then flush all
outstanding floats. In some pathological circumstances \texttt{afterpage}
may give strange results, however.

Finally, if you want a float only at the place where you define it, without
\latex/ moving it whatsoever, you can use the \textsf{float} package and
give the command:
\begin{verbatim}
\restylefloat{figure}
\end{verbatim}
 in the preamble. Now you will be able to
specify \texttt{[H]} as the position parameter, which will mean ``HERE and only
HERE''. This may cause an unwanted page break however. 
If you want to avoid the unwanted pagebreak, i.e. let
\LaTeX{} move the float only if it doesn't fit on the page, then use the
\textsf{afterpage} package with:
\begin{verbatim}
\afterpage{\clearpage \begin{figure}[H] ... \end{figure}}
\end{verbatim}

Complaints from \latex/ about ``Too many floats'' are usually caused by one
of the above problems: floats not being able to be placed and \latex/
collecting too many of them. The solutions given above, especially those
with \Cmd{clearpage} in them will usually help. In some cases there
really are too many floats, as \latex/ has a limited number of ``boxes'' to
store the floats. The package \textsf{morefloats} can be used to increase
this number. If you need still more then you must edit a private copy of
this file, but even then there will be some limit that you cannot pass.
Then your only resort will be to change your document.

\section{Multipage Floats}

\LaTeX's floats cannot be split across pages. Sometimes, however, you want
to have a table or figure that doesn't fit on one page. The easiest way is
to split these into multiple table or figure environments, but this has a
number of undesirable effects:
\begin{itemize}
\item Where do you split it? This is in general more difficult for tables
  than for figures.
\item How do you keep them together?
\item You don't want more than one entry in the list of figures/tables.
\end{itemize}

Although these problems are not fully solvable in all cases, here are a
couple of suggestions:


\subsection{Tables}

For tables longer than a page you can use the \texttt{longtable} package.
\TTindex{longtable}
This package defines a \texttt{longtable} environment that is a kind of
amalgamation of \texttt{table} and \texttt{tabular}. It has approximately
the same syntax as the  \texttt{tabular} environment, but it adds some
features of \texttt{table}, like captions. Longtables will be automatically
split when they don't fit on the page. And they will be entered in the list
of tables when a caption is given. They will not float, however, and cannot
be used inside a float environment. This could mean that another
\texttt{table} environment, which was defined before the
\texttt{longtable}, will float past it, and therefore the numbers may get
out of order. Another problem could be that the \texttt{longtable} starts
rather far down the page, which isn't a pleasant sight. If you want the
\texttt{longtable} to start at the top of the page, the best thing to do is
to include it in an \Cmd{afterpage} command (using the \texttt{afterpage}
package). As a \texttt{longtable} is by definition large, it is best to put
it in a separate file, and \Cmd{input} it in the \Cmd{afterpage} command:
\CmdIndex{afterpage}
\begin{verbatim}
\afterpage{\input{mytable}}
\end{verbatim}
\begin{verbatim}
\afterpage{\clearpage\input{mytable}}
\end{verbatim}
The last form has the additional advantage that most of the outstanding
floats will be printed first.


\subsection{Figures}

There isn't an equivalent \texttt{longfigure} solution, so for figures you
will usually have to split it yourself. In general this is less of a
problem. However, the problem you get now is how to keep them together,
i.e. how to get the parts on subsequent pages, and how to get a single
entry in the list of figures.

You will have to split the figure into pieces and put each part
in a separate \texttt{figure} environment. To keep them together it is best
to use only the \texttt{[p]} placement, so that they will be put on
floatpages. As they are bigger than a page this is appropriate. The first
part would then get a \Cmd{caption}, the subsequent parts would be used
without a caption. If you want to add a caption-like text, enter it as
normal text rather than a \Cmd{caption}, so that it will not be entered in
the list of figures. It may also be desirable to issue a \Cmd{clearpage}
first, just like we did for the \texttt{longtable}, and to encapsulate this
in the \Cmd{afterpage} command. E.g.
\begin{verbatim}
\afterpage{\clearpage\input{myfigure}}
\end{verbatim}
where \texttt{myfigure.tex} contains:
\begin{verbatim}
\begin{figure}[p]
\includegraphics{myfig1.eps}
\caption{This is a multipage figure}
\label{fig:xxx}
\end{figure}
\begin{figure}[p]
\includegraphics{myfig2.eps}
\begin{center}
Figure~\ref{fig:xxx} (continued)
\end{center}
\end{figure}
\end{verbatim}

You have to make sure that the last part is big enough, otherwise \LaTeX{}
could decide to postpone it until it has collected some more floats. This
can be done either by making the figure big enough (e.g. by adding some
\Cmd{vspace}), or by tweaking the \Cmd{floatpagefraction} 
\CmdIndex{floatpagefraction} parameter.

If you want your multipage figure to start at a lefthand-side
(even-numbered) page you can use a test in the \Cmd{afterpage} command
(using the \texttt{ifthen} package):
\begin{verbatim}
\afterpage{\clearpage
\ifthenelse{\isodd{\value{page}}{\afterpage{\input{myfigure}}} % odd page
    {\input{myfigure}}}} % even page
\end{verbatim}
If there are too many floats on the skipped page, this may still fail to
start your multipage figure on an even page, however.

\section{Contact information}

Piet van Oostrum\\
E-mail: piet@vanoostrum.org \\
WWW: http://www.pietvanoostrum.com

\section{Version information}
\begin{itemize}
\item  Version 1.0. March 11,  2003. This is the version that was distributed for a 
  long time on CTAN. Version history before this has been lost. 
\item Version 2.0. August 27, 2016:
  \begin{itemize}
  \item Removed references to fixmarks.sty as that is no longer used.
  \item References to older \LaTeX{} versions removed.
  \item Removed obsolete source code of \texttt{extramarks.sty}
  \item Changed font commands to \Cmd{textbf} and \Cmd{textsl}.
  \item Added description of the \Cmd{fancy\ldots offset} commands.
  \item Added various \Cmd{\ldots xmark} commands from \texttt{extramarks.sty}.
  \item Various corrections applied.
  \item Updated contact information.
  \item Added Version information. :)
  \end{itemize}
\item Version 2.1. August 28...., 2016:
  \begin{itemize}
  \item Explain what the top-marks are.
  \end{itemize}
\item Version 2.1. Sept. 6, 2016
  \begin{itemize}
  \item Add \verb|\string| to special indexing commands to get a neater index file.
  \item Add a decorative headrule example
  \end{itemize}

\end{itemize}

\printindex

\end{document}


% Local Variables:
% mode: latex
% TeX-master: t
% End: