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
|
% \iffalse meta-comment
%
% File: lastpage.dtx
% Version: 2011/08/08 v1.2i
%
% Copyright (C) 2010, 2011 by
% H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
% Portions of code copyrighted by other people as marked.
% This package was invented by Jeffrey P. Goldberg (jeffrey+news at goldmark dot org).
% I thought that a replacement was needed and therefore created the pageslts package,
% http://www.ctan.org/tex-archive/macros/latex/contrib/pageslts/pageslts.dtx
% or
% http://www.ctan.org/tex-archive/install/macros/latex/contrib/pageslts.tds.zip
% . Nevertheless, for compatibility with existing documents/packages as well as for
% the low amount of resources needed by the lastpage package (no new counter!),
% I updated this package.
% Thanks go to Jeffrey P. Goldberg for allowing me to do this.
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
% version. This version of this license is in
% http://www.latex-project.org/lppl/lppl-1-3c.txt
% and the latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work is H.-Martin Muench.
%
% This work consists of the main source file lastpage.dtx
% and the derived files
% lastpage.sty, lastpage.pdf, lastpage.ins, lastpage.drv,
% lastpage-example.tex.
%
% Distribution:
% CTAN:macros/latex/contrib/lastpage/lastpage.dtx
% CTAN:macros/latex/contrib/lastpage/lastpage.pdf
% CTAN:install/macros/latex/contrib/lastpage.tds.zip
%
% Unpacking:
% (a) If lastpage.ins is present:
% tex lastpage.ins
% (b) Without lastpage.ins:
% tex lastpage.dtx
% (c) If you insist on using LaTeX
% latex \let\install=y\input{lastpage.dtx}
% (quote the arguments according to the demands of your shell)
%
% Documentation:
% (a) If lastpage.drv is present:
% (pdf)latex lastpage.drv
% makeindex -s gind.ist lastpage.idx
% (pdf)latex lastpage.drv
% makeindex -s gind.ist lastpage.idx
% (pdf)latex lastpage.drv
% (b) Without lastpage.drv:
% (pdf)latex lastpage.dtx
% makeindex -s gind.ist lastpage.idx
% (pdf)latex lastpage.dtx
% makeindex -s gind.ist lastpage.idx
% (pdf)latex lastpage.dtx
%
% The class ltxdoc loads the configuration file ltxdoc.cfg
% if available. Here you can specify further options, e.g.
% use DIN A4 as paper format:
% \PassOptionsToClass{a4paper}{article}
%
% Installation:
% ! First, please make sure that there is no old version of !
% ! lastpage at some obsolete place in your system. !
% TDS:tex/latex/lastpage/lastpage.sty
% TDS:doc/latex/lastpage/lastpage.pdf
% TDS:doc/latex/lastpage/lastpage-example.tex
% TDS:source/latex/lastpage/lastpage.dtx
%
%<*ignore>
\begingroup
\catcode123=1 %
\catcode125=2 %
\def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
\ifx\csname processbatchFile\endcsname\relax\else1\fi
\ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{*********************************************************************}
\Msg{* Installation}
\Msg{* Package: lastpage 2011/08/08 v1.2i Refers to last page's name (HMM)}
\Msg{*********************************************************************}
\keepsilent
\askforoverwritefalse
\let\MetaPrefix\relax
\preamble
This is a generated file.
Project: lastpage
Version: 2011/08/08 v1.2i
Copyright (C) 2010, 2011 by
H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
Portions of code copyrighted by other people as marked.
The usual disclaimer applys:
If it doesn't work right that's your problem.
(Nevertheless, send an e-mail to the maintainer
when you find an error in this package.)
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3c of this license or (at your option) any later
version. This version of this license is in
http://www.latex-project.org/lppl/lppl-1-3c.txt
and the latest version of this license is in
http://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of
LaTeX version 2005/12/01 or later.
This work has the LPPL maintenance status "maintained".
The Current Maintainer of this work is H.-Martin Muench.
This package was invented by Jeffrey P. Goldberg.
I thought that a replacement was needed and therefore created the
pageslts package,
http://www.ctan.org/tex-archive/macros/latex/contrib/pageslts/pageslts.dtx
or
http://www.ctan.org/tex-archive/install/macros/latex/contrib/pageslts.tds.zip
. Nevertheless, for compatibility with existing documents/packages as well as
for the low amount of resources needed by the lastpage package (no new counter!),
I updated this package.
Thanks go to Jeffrey P. Goldberg for allowing me to do this.
This work consists of the main source file lastpage.dtx
and the derived files
lastpage.sty, lastpage.pdf, lastpage.ins, lastpage.drv,
lastpage-example.tex.
\endpreamble
\let\MetaPrefix\DoubleperCent
\generate{%
\file{lastpage.ins}{\from{lastpage.dtx}{install}}%
\file{lastpage.drv}{\from{lastpage.dtx}{driver}}%
\usedir{tex/latex/lastpage}%
\file{lastpage209.sty}{\from{lastpage.dtx}{lastpage209}}%
\file{lastpage.sty}{\from{lastpage.dtx}{package}}%
\usedir{doc/latex/lastpage}%
\file{lastpage-example.tex}{\from{lastpage.dtx}{example}}%
}
\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{* lastpage.sty (or lastpage209.sty for TeX 2.09)}
\Msg{*}
\Msg{* To produce the documentation run the file `lastpage.drv'}
\Msg{* through (pdf)LaTeX, e.g.}
\Msg{* pdflatex lastpage.drv}
\Msg{* makeindex -s gind.ist lastpage.idx}
\Msg{* pdflatex lastpage.drv}
\Msg{* makeindex -s gind.ist lastpage.idx}
\Msg{* pdflatex lastpage.drv}
\Msg{*}
\Msg{* At least three runs are necessary e.g. to get the}
\Msg{* references right!}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%
% \section{The documentation driver file}
%
% The next bit of code contains the documentation driver file for
% \TeX{}, i.\,e., the file that will produce the documentation you
% are currently reading. It will be extracted from this file by the
% \texttt{docstrip} programme. That is, run \LaTeX\ on \texttt{docstrip}
% and specify the \texttt{driver} option when \texttt{docstrip}
% asks for options.
%
% \begin{macrocode}
%<*driver>
\NeedsTeXFormat{LaTeX2e}[2009/09/24]
\ProvidesFile{lastpage.drv}[2011/08/08 v1.2i
Refers to last page's name (HMM)]
\documentclass{ltxdoc}[2007/11/11]% v2.0u
\usepackage{holtxdoc}[2011/02/04]% v0.21
%% lastpage may work with earlier versions of LaTeX2e and those
%% class and package, but this was not tested.
%% Please consider updating your LaTeX, class, and package
%% to the most recent version (if they are not already the most
%% recent version).
\hypersetup{%
pdfsubject={Refers to last page's name (HMM; JPG)},%
pdfkeywords={LaTeX, lastpage, last page, page number, page name, Hans-Martin Muench, Jeffrey P. Goldberg},%
pdfencoding=auto,%
pdflang={en},%
breaklinks=true,%
linktoc=all,%
pdfstartview=FitH,%
pdfpagelayout=OneColumn,%
bookmarksnumbered=true,%
bookmarksopen=true,%
bookmarksopenlevel=2,%
pdfmenubar=true,%
pdftoolbar=true,%
pdfwindowui=true,%
pdfnewwindow=true%
}
\usepackage{ulem}[2011/03/18]%
\CodelineIndex
\hyphenation{created every-thing ignored}
\gdef\unit#1{\mathord{\thinspace\mathrm{#1}}}%
\begin{document}
\DocInput{lastpage.dtx}%
\end{document}
%</driver>
% \end{macrocode}
%
% \fi
%
% \CheckSum{154}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \GetFileInfo{lastpage.drv}
%
% \begingroup
% \def\x{\#,\$,\^,\_,\~,\ ,\&,\{,\},\%}%
% \makeatletter
% \@onelevel@sanitize\x
% \expandafter\endgroup
% \expandafter\DoNotIndex\expandafter{\x}
% \expandafter\DoNotIndex\expandafter{\string\ }
% \begingroup
% \makeatletter
% \lccode`9=32\relax
% \lowercase{%^^A
% \edef\x{\noexpand\DoNotIndex{\@backslashchar9}}%^^A
% }%^^A
% \expandafter\endgroup\x
% \DoNotIndex{\documentclass,\usepackage,\ProvidesPackage}
% \DoNotIndex{\NeedsTeXFormat,\plainTeX,\TeX,\LaTeX,\pdfLaTeX}
% \DoNotIndex{\",\-,\,,\\,\noindent}
% \DoNotIndex{\textbf,\textit,\textsf,\texttt,\underline,\mathord,\normalsize}
% \DoNotIndex{\textquotedblleft,\textquotedblright}
% \DoNotIndex{\ifx,\ifnum,\gdef,\href,\pageref}
% \DoNotIndex{\newpage,\pagebreak,\newline,\linebreak,\nolinebreak,\MessageBreak}
% \DoNotIndex{\smallskip,\medskip,\bigskip,\space,\hfil,\qquad,\thinspace}
% \DoNotIndex{\listfiles,\section,\today,\the,\arabic}
% \DoNotIndex{\makeatletter,\makeatother,\verb}
% \DoNotIndex{\begin,\end,\enddocument,\mathrm}
%
% \title{The \xpackage{lastpage} package}
% \date{2011/08/08 v1.2i}
% \author{H.-Martin M\"{u}nch\\\xemail{Martin.Muench at Uni-Bonn.de}\\
% invented by Jeffrey P. Goldberg\\\xemail{jeffrey+news at goldmark.org}}
%
% \maketitle
%
% \begin{abstract}
% This \LaTeX\ package puts the label \texttt{LastPage}
% (|\AtEndDocument|) into the \xfile{.aux} file, allowing the user to refer
% to the last page of a document. This might be particularly useful
% in places like headers or footers.~--\\
% When more than one page numbering scheme is used, or the fnsymbol page
% numbering scheme is used, or another package has output after this package,
% or the number of pages instead of the last page's name is needed,
% or the page numbers exeed a certain range, there might be problems,
% which can be solved by using the \xpackage{pageslts} package instead.
% \end{abstract}
%
% \bigskip
%
% \noindent Disclaimer for web links: The author is not responsible for any contents
% referred to in this work unless he has full knowledge of illegal contents.
% If any damage occurs by the use of information presented there, only the
% author of the respective pages might be liable, not the one who has referred
% to these pages.
%
% \bigskip
%
% \noindent {\color{green} Save per page about $200\unit{ml}$ water,
% $2\unit{g}$ CO$_{2}$ and $2\unit{g}$ wood:\\
% Therefore please print only if this is really necessary.}
%
% \pagebreak
%
% \tableofcontents
%
% \pagebreak
%
% \section{Introduction}
%
% \indent This \LaTeX\ package puts the label \texttt{LastPage}
% (|\AtEndDocument|) into the \xfile{aux} file, allowing the user to refer
% to the last page of a document via |\pageref{LastPage}|.
% This might be particularly useful in places like headers or footers.
%
% \bigskip
%
% This package was invented by \textbf{Jeffrey P. Goldberg},
% and is now maintained by \textsc{H.-Martin M\"{u}nch}. A~big
% \textquotedblleft Thank you!\textquotedblright\ to
% \textsc{Jeffrey P. Goldberg} for granting this.
%
% \bigskip
%
% If you are more ambitiouse in respect to your aims with this package,
% you might want to have a look at the \xpackage{pageslts} package
% (see section~\ref{sec:Alternatives}: Alternatives).
%
% \bigskip
%
% \section{Usage}
%
% \indent Just load the package placing
% \begin{quote}
% |\usepackage{lastpage}|
% \end{quote}
% \noindent in the preamble of your \LaTeXe\ source file or
% \begin{quote}
% |\usepackage{lastpage209}|
% \end{quote}
% \noindent in the preamble of your \LaTeX2.09\ source file.\\
%
% \indent For example for various draft forms it is desirable to have a
% page reference to the last page, so that e.\,g. page footers can
% contain something like \textquotedblleft page $N$ of $K$\textquotedblright,
% where $N$ is the current page and $K$ is the last page. Once the package
% is loaded, anywhere in the text references can be made to the label
% \texttt{LastPage}. In particular one can use the \xpackage{fancyhdr}
% or \xpackage{nccfancyhdr} package, or redefinitions of the page headings
% and footings to get a reference to the last page.
%
% \noindent In your document the code
% \begin{verbatim}
% \makeatletter
% \renewcommand{\@evenfoot}{%
% \normalsize\slshape DRAFT \today\hfil \upshape %
% page {\thepage} of \pageref{LastPage}}
% \renewcommand{\@oddfoot}{\@evenfoot}
% \makeatother
%\end{verbatim}
% \noindent creates footers like\\
%
% \textquotedblleft\mbox{\textsl{DRAFT \today}\hspace{1cm}page 7 of 9}\textquotedblright\\
%
% \noindent in the compiled document (cf.~the \texttt{lastpage-example} file).\\
% If the \xpackage{hyperref} package is used, the references are hyperlinked
% to their aims. If these hyperlinks shall be suppressed, |\pageref*{...}|
% instead of |\pageref{...}| can be used.\\
%
% The \xpackage{lastpage} package does not provide the words
% \textquotedblleft page\textquotedblright\ or \textquotedblleft of\textquotedblright{},
% but e.\,g. the \xclass{handout} class uses \textquotedblleft of\textquotedblright\ in
% the definition of the footer. (In the \texttt{lastpage-example} also
% |\@evenfoot| is redefined, but it is not the \xpackage{lastpage} \emph{package}
% redefining this.) If you want to change \textquotedblleft page\textquotedblright\ or
% \textquotedblleft of\textquotedblright\ (e.\,g. to another language), you therefore
% have got to look in the used class/package(s)/preamble instead of in the
% \xpackage{lastpage} package.\\
%
% \section{A lot of WARNINGS\label{sec:warn}}
%
% \indent (Short: try using the \xpackage{pageslts} package instead,
% if you have room for some more |\count|ers.\footnote{To determine the number of%
% used and available counters and other registers, the \xpackage{regstats} package%
% might be helpful.})
%
% \subsection{\texttt{\textbackslash AtEndDocument}\label{ssec:aed}}
%
% \indent The output of a \LaTeXe\ run is not independent of the order
% in which the packages are loaded. It is often the case that the same
% formats for which one must put tables and figure at the end,
% are the ones in which endnotes are also required.
% If one wants to use |\AtEndDocument| here as well (as done for
% |\pageref{LastPage}|), then it is easy to get to three separate
% uses of |\AtEndDocument| (assuming one uses this for the endnotes
% as well). Clearly it is not safe for any package writer or user
% to assume that no material will follow what they put into
% |\AtEndDocument|. Therefore a message, which begins with
% \texttt{AED}, is included in every usage of |\AtEndDocument|.~--\\
% \indent (The \xpackage{pageslts} package solves this problem by using
% |\AfterLastShipout| from \textsc{Heiko Oberdiek's} \xpackage{atveryend}
% package for the references\\
% |\lastpageref{VeryLastPage}| and |\lastpageref{LastPages}|.)
%
% \subsection{Interaction with very old versions of the \xpackage{endfloat} package\label{sec:endfloat}}
%
% \indent The \emph{very} old version~2.0 (and earlier) of the \xpackage{endfloat}
% package actually redefined the |\enddocument| command, and so interferred
% drastically with the \LaTeXe\ commands which make use of |\AtEndDocument|.
% Newer versions of \xpackage{endfloat} exists \linebreak
% (at the time of writing this documentation: v2.4i as of 1995/10/11)
% in modern documentation form, which should be available from
% the same source where you received this file, see subsection~\ref{ss:Downloads}.\\
% A note is placed in the style file.
% If you want your \texttt{LastPage} to label the last page of these end floats,
% you need to load \xpackage{lastpage} after loading \xpackage{endfloat}
% (or use \texttt{VeryLastPage} from the \xpackage{pageslts} package instead).
% If, on the other hand, you \emph{want} \texttt{LastPage} to refer
% to the (not so) last page, exclusive of the the floats at the end,
% then load in the reverse order. Independent from the order of
% \xpackage{lastpage} and \xpackage{endfloat}, you will still need the
% modified\footnote{The \textquotedblleft new\textquotedblright\ version
% is over 15~years old, so it might be time to update to this version, \linebreak
% if you did not do it already.} version of \xpackage{endfloat}.\\
%
% Other \LaTeX2.09\ (!) packages also seem to like to redefine
% |\enddocument|. In addition to the old \xpackage{endfloat},
% \xpackage{harvard} comes to mind. All of these will need to be
% modified swiftly. \textbf{If possible, update to \LaTeXe{}!}
%
% \subsection{Page name instead of page number}
%
% When any page numbering scheme other than \texttt{arabic} is used
% at the page, which |\pageref{LastPage}| referes to, the \textit{name}
% and not the \textit{number} of the page is given. For example,
% \texttt{Alph} page numbering scheme and $10$ pages will give \texttt{J} instead of 10,
% \texttt{Roman} page numbering scheme and $10$ pages will give \texttt{X} instead of 10,
% and so on.\\
% \indent (The \xpackage{pageslts} package puts |\lastpageref{LastPages}|
% (with \textbf{s} at the end) at your disposal for remediation.)
%
% \subsection{Wrong last page number with more than one page numbering scheme}
%
% When more than one page numbering scheme is used,
% \texttt{LastPage} does not give the total \textbf{number} of pages
% (even if \texttt{arabic} is the page numbering scheme of that page).
% For example, for a document with VI+36 pages, it gives
% \textquotedblleft 36\textquotedblright\ as reference to the last page.
% While this is correct, the total number of pages is $42$.\\
% \indent (The \xpackage{pageslts} package puts |\lastpageref{LastPages}|
% (with \textbf{s} at the end) at your disposal for remediation.)
%
% \subsection{\texttt{\textbackslash addtocounter\{page\}\{\ldots\} and \texttt{\textbackslash setcounter\{page\}\{\ldots\}}}}
%
% When the page number was manipulated by |\addtocounter{page}{...}| or
% |\setcounter{page}{...}|, \texttt{LastPage} does not give the total
% \textbf{number} of pages (even if \texttt{arabic} is the page numbering
% scheme of that page).\\
% \indent (The \xpackage{pageslts} package puts |\lastpageref{LastPages}|
% (with \textbf{s} at the end) at your disposal for remediation:
% \texttt{LastPages} ignores page number manipulation.)
%
% \subsection{Page number reset by \texttt{\textbackslash pagenumbering\{\ldots\}}}
%
% At a page numbering change the page number is reset to one.
% Therefore \texttt{LastPage} does not give the total \textbf{number} of pages
% (even if \texttt{arabic} is the page numbering scheme of that page).
% Furthermore, now two pages have the same name.\\
% \indent (The \xpackage{pageslts} package does not only put
% |\lastpageref{LastPages}| (with \textbf{s} at the end) at your disposal
% for remediation: \texttt{LastPages} also ignores page number manipulation.
% It furthermore offers the option |pagecontinue| to continue the
% page numbering, when |\pagenumbering{...}| is used.)
%
% \subsection{Last pages of different page numbering schemes}
%
% |\pageref{LastPage}| referes to the (maybe not so) last page of the last
% page numbering scheme. References to the respective last page of the other
% page numbering schemes are not provided.\\
% \indent (The \xpackage{pageslts} package does this with labels
% \texttt{pagesLTS.<numbering scheme>}, where \texttt{<numbering scheme>} is
% e.\,g. arabic, roman, Roman, alph, or Alph.\linebreak
% For fnsymbol please use |\lastpageref{pagesLTS.fnsymbol}| instead of\\
% |\pageref{pagesLTS.fnsymbol}|.)
%
% \subsection{Current page}
%
% The command |\thepage| gives the \textbf{name} of the current page
% in the current page numbering scheme, which is different from the
% current total/absolute page number e.\,g. with a second
% page numbering scheme, |\addtocounter{page}{...}|, or |\setcounter{page}{...}|,
% and it will not be an arabic number at all,
% if the current page numbering scheme is not arabic.\\
% \indent (The \xpackage{pageslts} package provides the command
% |\theCurrentPage| and for the current number of pages in the current
% page numbering scheme\\
% |\theCurrentPageLocal|.)
%
% \subsection{First page}
%
% There is no special label at the first page.
% (This is the \textbf{last}\textsf{page} package, after all.)\\
% \indent (The \xpackage{pageslts} package creates a label \texttt{pagesLTS.0}
% at the first page of the document.)
%
% \subsection{Using the \xpackage{fnsymbol} page numbering scheme\label{ss:fnsymbol}}
%
% \indent Using the \texttt{fnsymbol} page numbering scheme can result in problems!\\
% When the page, where |\pageref{lastpage}| points at, is in \texttt{fnsymbol}
% page numbering scheme, this package might skrew up --
% and quite totally for that, especially when used together with old versions of the
% \xpackage{hyperref} package (e.\,g. \xpackage{hyperref} v6.80x as of 2010/04/17).
% When testing with version v6.82g as of 2011/04/17, the hyperlink did not aim
% at the last page, but at least the given name of the last page was right.\\
% \indent (The \xpackage{pageslts} package with |\lastpageref{lastpage}| and
% appropriate package options should cope even with this case.)
%
% \subsection{Page counter overflow\label{ss:overflow}}
%
% \indent \textquotedblleft The ranges of supported counter values are more or less
% restricted. Only \cs{arabic} can be used with any counter value \TeX\ supports.
% \begin{quote}
% \catcode`\|=12 %
% \begin{tabular}{@{}l|l|l|l@{}}
% Presentation & Supported & Ignored & Error message\\
% command & domain & values & `Counter too large'\\
% \hline
% \cs{arabic}
% & \ttfamily -MAX..MAX & &\\
% \cs{roman}, \cs{Roman}
% & \ttfamily 1..MAX & \ttfamily -MAX..0 &\\
% \cs{alph}, \cs{Alph}
% & \ttfamily 1..26 & 0 & \ttfamily -MAX..-1, 27..MAX\\
% \cs{fnsymbol}
% & \ttfamily 1..9 & 0 & \ttfamily -MAX..-1, 10..MAX\\
% \hline
% \end{tabular}\\[1ex]
% \texttt{MAX} = \texttt{2147483647}
% \end{quote}
% \textquotedblright\ (\textsc{Heiko Oberdiek}:
% The \xpackage{alphalph} package, 2010/04/18, v2.3, first table, p.~2).\\
%
% \noindent When \textit{any} page is out of that range, there will be a counter overflow.\\
% \indent (\xpackage{lastpage} probably is not the right package to be asked
% to correct this anyway, but the \xpackage{pageslts} package
% (with appropriate options) can do this.)\\
%
%\subsection{Other packages manipulating \texttt{\textbackslash lastpage@putlabel}}
%
% The \xpackage{hyperref} package redefines the |\lastpage@putlabel| command,
% and the \xpackage{revtex4} class redefines the |\lastpage@putlabel| command,
% and the \xpackage{hyperref} package redefines the |\lastpage@putlabel| command,
% if the \xpackage{revtex4} class is used, and the \xpackage{pageslts}
% \textquotedblleft kills\textquotedblright\ the |\lastpage@putlabel| command,
% because that package uses more advanced labels.\\
% In my humble opinion it would be preferably if one package (the original one,
% i.\,e. \xpackage{lastpage}) would do the job right, all others packages would
% check for the version of that package, and if an old version is found,
% an error (or at least a warning) message about the use of an outdated
% package is given, and \textit{then} as
% \textquotedblleft last aid\textquotedblright\ the command of the outdated
% package is redefined.\\
% Therefore here none of the definitions or commands of the other packages
% is altered, but |\lastpage@putlabel| was replaced by |\lastpage@putl@bel|.
% Because |\lastpage@putlabel| is no longer called, now there should not be any
% double definitions of the \texttt{lastpage} label.\\
%
% \pagebreak
%
% \section{Alternatives\label{sec:Alternatives}}
%
% There are similar packages, which do (or do not) similar things (or even more).
% As I neither know what exactly you want to accomplish when using this package
% (e.\,g.~page number vs. page name, hyperlinks or not), nor what resources
% you have (e.\,g.~\eTeX{}), here is a list of some possible alternatives:\\
%
% \DescribeMacro{lastpage209.sty}
% \begin{description}
% \item[-] If \LaTeX2.09\ is still used, and if you are unable to switch to
% \LaTeXe{}, the \LaTeX2.09\ compatible \xpackage{lastpage209.sty} can be used,
% which is defined as follows:\\
% (It is also generated automatically from \xfile{lastpage.dtx} when compiling it.)
%
% \begin{macrocode}
%<*lastpage209>
% FOR LaTeX 2.09 ONLY - FOR LaTeX 2e USE lastpage.sty OR pageslts.sty!
% This is lastpage209.sty invented by Jeffrey P. Goldberg
% (jeffrey+news at goldmark dot org), maintained by
% H.-Martin M\"{u}ench (Martin dot Muench at Uni-Bonn dot de).
\let\origenddocument=\enddocument%
\def\enddocument{\clearpage%
{\addtocounter{page}{-1}%
\immediate\write\@mainaux{\string\newlabel{LastPage}{{}{\thepage}}}}%
\addtocounter{page}{+1}%
\origenddocument%
}%
%</lastpage209>
% \end{macrocode}
%
% (after \textsc{Piet van Oostrum}: Page layout in \LaTeX{}, March~2, 2004,
% section~16; fancyhdr.pdf). Because |\enddocument| is redefined,
% similar problems as with the old version of the \xpackage{endfloat}
% package (see subsection~\ref{sec:endfloat}) will arise.\\
% \textbf{If possible, update to \LaTeXe{}}\ (and maybe to the
% \xpackage{pageslts} package)\textbf{!}
% \end{description}
%
% \DescribeMacro{pageslts}
% \begin{description}
% \item[-] The \xpackage{pageslts} package first started as a revision of this
% \xpackage{lastpage} package, but it became obviouse that a replacement was
% needed to accomplish what the \xpackage{pageslts} package does. For backward
% compatibility, a label named |LastPage| is provided.
% Thus |\usepackage{lastpage}| can be replaced by\\
% |\usepackage[pagecontinue=false,alphMult=0,AlphMulti=0,|\\
% | fnsymbolmult=false,romanMult=false,RomanMulti=false]{pageslts}|,\\
% if the behaviour of the \xpackage{lastpage} package should be simulated.
% The default options are\\
% |\usepackage[pagecontinue=true,alphMult=ab,AlphMulti=AB,|\\
% |fnsymbolmult=true,romanMult=true,RomanMulti=true]{pageslts}|.\\
% Benefits of \xpackage{pageslts} package (with appropriate options) are:
% \begin{description}
% \item[+] Labels \texttt{LastPage} (|\AtEndDocument|) and\\
% \texttt{VeryLastPage} (|\AfterLastShipout|),\\
% allowing the user to refer to the (very) last page of a document.
% \item[+] For example, when more than one page numbering scheme is used,
% the label \texttt{LastPage}\textbf{s} gives the total \textit{number} of pages.
% \item[+] At the last page of each page numbering
% scheme a label\\
% \texttt{pagesLTS.<numbering scheme>} is
% placed, where \texttt{<numbering scheme>} is e.\,g.
% arabic, roman, Roman, alph, or Alph. For fnsymbol
% please use |\lastpageref{pagesLTS.fnsymbol}| instead of\\
% |\pageref{pagesLTS.fnsymbol}|.
% \item[+] When the same numbering scheme is used twice, the page numbers
% are either reset to one or continued automatically, depending on the option
% given when the package is called.
% \item[+] The command |\theCurrentPage| prints the current total/absolute
% page number -- in contrast to |\thepage|, which gives only the page
% \textit{name} in the current page numbering scheme.
% |\theCurrentPageLocal| gives the current number of pages in the current
% page numbering scheme. |\thepage| and |\theCurrentPageLocal| are different
% e.\,g. when |\addtocounter{page}{...}| or |\setcounter{page}{...}| were used.
% \item[+] At the first page of the document a label \texttt{pagesLTS.0} is created.
% \item[+] The \xpackage{alphalph} package is supported, i.\,e.
% page numbers alph or Alph $>26$ and fnyambol $>9$ can be used
% (with according options set). Even zero and negative page numbers can be used
% with \texttt{arabic}, \texttt{alph}, \texttt{Alph}, \texttt{roman}, \texttt{Roman},
% and \texttt{fnsymbol} page numbering (with \xpackage{alphalph} package and
% according options).
% \item[+] It is checked whether a (very) old \xpackage{endfloat} package
% is in use. If it is, a warning or even an error message is given,
% depending on \xpackage{endfloat} version.
% \item[+] A rerun warning is given, when labels have changed.
% \end{description}
% Further labels are provided for special cases.
% \end{description}
%
% \DescribeMacro{totpages}
% \begin{description}
% \item[-] The \xpackage{totpages} package provides a \texttt{totpages} label similar to
% \texttt{LastPages}\\
% |\AtEndDocument| (instead of |\AfterLastShipout|, as done by \xpackage{pageslts}).
% The \xpackage{totpages} package additionally computes the number of paper sheets
% needed to (double) print the document (with one, two, three,\ldots{} pages on
% one sheet of paper) (which can be achived also with the \xpackage{papermas} package,
% an extension of the \xpackage{pageslts} package, which further allows to compute
% the mass of that printed version of the document, useful e.\,g. when sending it
% by mail to determine the postage).
% \end{description}
%
% \DescribeMacro{nofm.sty}
% \begin{description}
% \item[-] \textquotedblleft There is a package \xpackage{nofm.sty} available,
% but some versions of it are defective, and most don't work with \xpackage{fancyhdr}
% because they take over the complete page layout.\textquotedblright (\textsc{Piet van %
% Oostrum}: Page layout in \LaTeX{}, March~2, 2004, section~16; fancyhdr.pdf)\\
% \xpackage{nofm} as of 1991/02/25 (without version number), available at\\
% \url{ftp://tug.ctan.org/pub/tex-archive/obsolete/macros/latex209/contrib/misc/nofm.sty},\\
% does not work with e.\,g. \xpackage{hyperref}, redefines |\enddocument|
% as well as |\@oddhead|, |\@evenhead|, |\@oddfoot|, and |\@evenfoot|.\\
% If you know the (\CTAN{}) location of a \textbf{working}~(!) version,
% please send an e-mail to the \xpackage{lastpage} maintainer, thanks!
% \end{description}
%
% \DescribeMacro{count1to}
% \begin{description}
% \item[-] You may want to have a look at the \xpackage{count1to} package.
% \end{description}
%
% \DescribeMacro{zref}
% \begin{description}
% \item[-] The \xpackage{zref} package of \textsc{Heiko Oberdiek} requires
% $\varepsilon$-\TeX{}. \xpackage{lastpage} does not require $\varepsilon$-\TeX{},
% but if you already have $\varepsilon$-\TeX{}, you may have a look at the extensive
% \xpackage{zref} package, whether it suits your needs better (or additionally or
% whatsoever).
% \end{description}
%
% \bigskip
%
% \noindent (You programmed or found another alternative,
% which is available at \CTAN{}?\\
% OK, send an e-mail to me with the name, location at \CTAN{},
% and a short notice, and I will probably include it in the list above.)\\
%
% \smallskip
%
% \noindent About how to get those packages, please see subsection~\ref{ss:Downloads}.
%
% \pagebreak
%
% \section{Example}
%
% \begin{macrocode}
%<*example>
\documentclass[british]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\AtEndDocument{\message{^^JLaTeX Info: Executing hook `AtEndDocument'.}}
\usepackage[draft]{showkeys}[2007/08/07]% v3.15
%% Use final instead of draft to hide the keys. %%
\usepackage{hyperref}[2011/04/17]% v6.82g
\hypersetup{%
extension=pdf,%
plainpages=false,%
pdfpagelabels=true,%
hyperindex=false,%
pdflang={en},%
pdftitle={lastpage package example},%
pdfauthor={Hans-Martin Muench},%
pdfsubject={Example for the lastpage package},%
pdfkeywords={LaTeX, lastpage, Hans-Martin Muench},%
pdfview=Fit,%
pdfstartview=Fit,%
pdfpagelayout=SinglePage%
}
\usepackage{lastpage}[2011/08/08]% v1.2i
\makeatletter
\renewcommand{\@evenfoot}{%
\normalsize\slshape \today\hfil \upshape page \thepage%
\ of \pageref{LastPage}}
\renewcommand{\@oddfoot}{\@evenfoot}
\makeatother
\gdef\unit#1{\mathord{\thinspace\mathrm{#1}}}%
\listfiles
\begin{document}
\pagenumbering{Roman}
\section*{Example for lastpage}
\markboth{Example for lastpage}{Example for lastpage}
This example demonstrates the use of package\newline
\textsf{lastpage}, v1.2i as of 2011/08/08 (HMM; JPG).\newline
The package takes no options.\newline
For more details please see the documentation!\newline
\noindent \label{keys} To hide the \pageref{keys}{\qquad } use option
\texttt{final} instead of \texttt{draft} with the \textsf{showkeys}
package (or remove the package call from the preamble of
this document).\newline
\textbf{Hyperlinks or not:} If the \textsf{hyperref} package is loaded,
the references are also hyperlinked:\newline
\smallskip
Last page's name (LastPage): \pageref{LastPage}\newline
\noindent If the \textsf{hyperref} package is loaded, but the hyperlinks
of the references shall be suppressed, \verb|\pageref*{...}|
can be used:\newline
\smallskip
Last page's name (LastPage): \pageref*{LastPage}\newline
\textbf{Trademarks} appear throughout this example without any
trademark symbol; they are the property of their respective
trademark owner. There is no intention of infringement; the
usage is to the benefit of the trademark owner.\newline
\textbf{Tip}: Use \textit{logical page numbers} for
the display of the pdf!\newline
(In Adobe Reader X (10.1.0): \underline{E}dit $>$
Prefere\underline{n}ces (Ctrl+k) $>$ Page Display $>$
Page Content and Information $>$ Use logical page
\nolinebreak{\underline{n}umbers.)}\newline
If you are more ambitiouse in respect to your aims with this package,
you might want to have a look at the \textsf{pageslts} package\newline
\makeatletter
\@ifundefined{Hy@Warning}{% hyperref not loaded
\verb|http://www.ctan.org/tex-archive/macros/latex/contrib/pageslts/|).
}{% hyperref loaded
\href{http://www.ctan.org/tex-archive/macros/latex/contrib/pageslts/}{%
CTAN:/macros/latex/contrib/pageslts/}).
}%
\makeatother
\bigskip
Save per page about $200\unit{ml}$~water, $2\unit{g}$~CO$_{2}$
and $2\unit{g}$~wood:\newline
Therefore please print only if this is really necessary.\newline
I do NOT think, that it is necessary to print THIS file, really\newline
(at least not after this page)!
\bigskip
\noindent The page (\verb|\thepage|): \thepage \newline
\noindent Last page's name (LastPage): \pageref{LastPage}
\newpage
\noindent The page (\verb|\thepage|): \thepage \newline
\noindent Last page's name (LastPage): \pageref{LastPage}
\newpage
\noindent The page (\verb|\thepage|): \thepage \newline
\noindent Last page's name (LastPage): \pageref{LastPage}
\newpage
\section*{The End}
\noindent The page (\verb|\thepage|): \thepage \newline
\noindent Last page's name (LastPage): \pageref{LastPage}
\end{document}
%</example>
% \end{macrocode}
%
% \newpage
%
% \StopEventually{}
%
% \section{The implementation}
%
% We start off by checking that we are loading into \LaTeXe\ and
% announcing the name and version of this package.
%
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[2009/09/24]
\ProvidesPackage{lastpage}[2011/08/08 v1.2i
Refers to last page's name (HMM; JPG)]%
% \end{macrocode}
%
% A short description of the \xpackage{lastpage} package:
%
% \begin{macrocode}
%% Allows for things like
%% Page \thepage\ of \pageref{LastPage}
%% to get
%% 'Page 7 of 9'.
% \end{macrocode}
%
% A last information for the user(s):
%
% \begin{macrocode}
%% For LaTeX 2.09 use lastpage209.sty.
%% For LaTeX 2e maybe consider upgrading to the pageslts package.
%% lastpage may work with earlier versions of LaTeX2e,
%% but this was not tested. Please consider updating your LaTeX
%% contribution to the most recent version (if it is not already
%% the most recent version).
% \end{macrocode}
%
% The very old version~2.0 (and earlier) of the \xpackage{endfloat}
% package actually redefined the |\enddocument| command,
% and so interferred drastically with the \LaTeXe\ commands which
% make use of |\AtEndDocument|. Newer versions of \xpackage{endfloat}
% exists (at the time of writing this documentation: v2.4i as of 1995/10/11)
% in modern documentation form, which are available from \CTAN{}
% (see subsection~\ref{ss:Downloads}).
% A~note is placed here. (The \xpackage{pageslts} package even checks whether
% a (very) old \xpackage{endfloat} package is in use. If it is, a warning or
% even an error message is given, depending on \xpackage{endfloat} version.)
%
% \begin{macrocode}
%% The recent version of the endfloat package is v2.4i as of 1995/10/11.
%% The lastpage package is not fully compatible with version 2.0
%% (and earlier) of the endfloat package, because those versions
%% redefined the \enddocument command.
% \end{macrocode}
%
% There are no options to be introduced.\\
%
% \indent For comparisons, \textquotedblleft one\textquotedblright\ is defined
% (|\@ne| does not work for this).
%
% \begin{macrocode}
\def\lastpage@one{1}
% \end{macrocode}
%
% We define |\lastpage@hyper| and |\lastpage@LTS| to be
% \textquotedblleft \texttt{0}\textquotedblright{}.
%
% \begin{macrocode}
\gdef\lastpage@hyper{0}
\gdef\lastpage@LTS{0}
% \end{macrocode}
%
% We define |\lastpage@firstpage| to be \textquotedblleft \texttt{1}\textquotedblright{}.
%
% \begin{macrocode}
\def\lastpage@firstpage{1}
% \end{macrocode}
%
% \pagebreak
%
% \begin{macro}{\AtBeginDocument}
% \indent |\AtBeginDocument| it is checked whether the \xpackage{hyperref} package
% is loaded.\\
% (|\@ifpackageloaded| cannot be used later than |\AtBeginDocument|.)\\
% If this is the case, |\lastpage@hyper| is defined as \texttt{1}
% (otherwise it stays \texttt{0}).
%
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{hyperref}{\gdef\lastpage@hyper{1}}{}%
\@ifpackageloaded{pageslts}{%
\PackageWarning{lastpage}{Package pageslts found.\MessageBreak%
Therefore the lastpage package is no longer\MessageBreak%
necessary.%
}%
\gdef\lastpage@LTS{1}%
}{\PackageInfo{lastpage}{%
Please have a look at the pageslts package at\MessageBreak%
http://www.ctan.org/tex-archive/ \MessageBreak%
macros/latex/contrib/pageslts/ \MessageBreak%
or\MessageBreak%
http://www.ctan.org/tex-archive/ \MessageBreak%
install/macros/latex/contrib/pageslts.tds.zip\MessageBreak%
!}%
}%
\@ifpackageloaded{pagesLTS}{%
\PackageWarning{lastpage}{%
Outdated pagesLTS package found.\MessageBreak%
Please replace by a recent version of\MessageBreak%
pageslts package, see e.g. at\MessageBreak%
http://www.ctan.org/tex-archive/ \MessageBreak%
macros/latex/contrib/pageslts/ \MessageBreak%
or\MessageBreak%
http://www.ctan.org/tex-archive/ \MessageBreak%
install/macros/latex/contrib/pageslts.tds.zip\MessageBreak%
!\MessageBreak%
With pagesLTS as well as pageslts package\MessageBreak%
the lastpage package is no longer necessary.\MessageBreak%
}%
\gdef\lastpage@LTS{1}%
}{}%
% \end{macrocode}
%
% |\lastpage@putlabel|, used by older versions of this package,
% is redefined e.\,g. by \xpackage{revtex} and \xpackage{hyperref}.
% While now |\lastpage@putl@bel| is used instead, \xpackage{revtex}
% or \xpackage{hyperref} could also define a lable \texttt{LastPage},
% which then would be multiply defined. (Which is no big issue,
% if it is associated with the same page.) Therefore we define
%
% \begin{macrocode}
\gdef\lastpage@putlabel{\relax}%
% \end{macrocode}
%
% Because |\lastpage@putlabel| might be (re)defined later, depending on the order
% in which the packages are loaded, we will do this again |\AtEndDocument|.
%
% \begin{macrocode}
}
% \end{macrocode}
% \end{macro}
%
% \pagebreak
%
% \begin{macro}{\lastpage@putl@bel}
% \indent This command does the writing of the label:
%
% \begin{macrocode}
\newcommand{\lastpage@putl@bel}{%
% \end{macrocode}
%
% |\AtBeginDocument| it is checked whether the \xpackage{hyperref} package is loaded,\\
% |\@ifpackageloaded{hyperref}{\gdef\lastpage@hyper{1}}{}|.\\
% |\@ifpackageloaded| cannot be used later than |\AtBeginDocument|.\\
% User \textsc{Sebastian Bank} found and reported (Thanks!) a~case, when this check is not
% sufficient. Using a class with\\
% |\usepackage{lastpage}|\\
% |\AtBeginDocument{\usepackage{hyperref}}|\\
% leads to failed detection of the \xpackage{hyperref} package, because
% |\AtBeginDocument| \textit{first} the check for \xpackage{hyperref} is performed,
% and \textit{then} \xpackage{hyperref} is loaded. As mentioned above,
% |\@ifpackageloaded| cannot be used later, so here we do not check for the
% \xpackage{hyperref} package again, but for its |\Hy@Warning| command.
% In version~1.2c of the \xpackage{lastpage} package, it was checked for
% the |\hyperref| command, but as it turned out, \xpackage{tcilatex} \textit{is}
% defining that. If some other package or user is defining |\Hy@Warning|,
% \xpackage{lastpage} will falsely assume, that \xpackage{hyperref} has been loaded,
% but in my humble opinion, defining |\Hy@Warning| does not make sense and
% is bad style (except definition by the \xpackage{hyperref} package itself,
% of course).
%
% \begin{macrocode}
\@ifundefined{Hy@Warning}{% hyperref not loaded
}{\gdef\lastpage@hyper{1}% hyperref loaded
}%
% \end{macrocode}
%
% If the \xpackage{pageslts} package is used, this \xpackage{lastpage} package is
% not needed at all. The \xpackage{LastPage} label would even be defined twice.
% Thus, if \xpackage{pageslts} is used, here nothing is done:
%
% \begin{macrocode}
\ifx\lastpage@LTS\lastpage@one%
\else%
% \end{macrocode}
%
% Otherwise the label is set:\\
% We have got to distinguish whether \xpackage{hyperref} has been loaded or not:
%
% \begin{macrocode}
\ifx\lastpage@hyper\lastpage@one%
\lastpage@putlabelhyper%
\else%
% \end{macrocode}
%
% When \xpackage{hyperref} has not been loaded, we just write the
% simple label into the \xfile{aux} file:
%
% \begin{macrocode}
\begingroup
\addtocounter{page}{-1}%
\immediate\write\@auxout{\string\newlabel{LastPage}{{}{\thepage}}}%
\addtocounter{page}{+1}%
\endgroup
\fi%
\fi%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lastpage@putlabelhyper}%
% \indent When \xpackage{hyperref} has been loaded, the label is set with the
% |\lastpage@putlabelhyper| command. If the \xpackage{hyperref} package is used,
% but pageanchors are disabled, the hyperlinking will not work.
%
% \begin{macrocode}
\newcommand{\lastpage@putlabelhyper}{%
\ifHy@pageanchor%
\else%
\PackageError{lastpage}{hyperref option pageanchor disabled}{%
The \string\pageref{LastPage} link doesn't work\MessageBreak%
using hyperref with disabled option `pageanchor'.\MessageBreak%
}%
\fi%
% \end{macrocode}
%
% Since the page has been put out, we are on the page \textit{after} that page.
% We therefore subtract one from the page counter. (For the compiler,
% this is equal to |\advance\c@page\m@ne|, but for human readers of the code
% it is probably easier to understand.)
%
% \begin{macrocode}
\begingroup%
\addtocounter{page}{-1}%
% \end{macrocode}
%
% Simply using |\label| for \texttt{LastPage} would not work,
% because labels wait for the output routines to work, and there
% may be no more invocations of the output routines. To force
% the write out, we need to do an |\immediate| write into the \xfile{aux} file.
%
% \begin{macrocode}
%% The following code is from the hyperref package %%
%% [2010/04/17 v6.80x; newer versions are available] %%
%% by Heiko Oberdiek (Big Thanks!). %%
\let\@number\@firstofone
\ifHy@pageanchor
\ifHy@hypertexnames
\ifHy@plainpages
\def\Hy@temp{\arabic{page}}%
\else
\Hy@unicodefalse
%% Code not from hyperref package: %%
%% The following lines are taken from the pageslts package, %%
%% which in turn got them from the hyperref package and %%
%% modified them. %%
%% Without the modification, after the first shipout "PD1" %%
%% is inserted each time |\pdfstringdef\Hy@temp{\thepage}| %%
%% is executed. %%
\ifnum \value{page}=1%
% \end{macrocode}
%
% We do not count the pages ourselfes, and so they could have been changed by
% e.\,g. |\pagenumbering{...}|, |\addtocounter{page}{...}|,\\
% |\setcounter{page}{...}|. Thus the page might have the number one
% while not beeing the first page at all. Using the \xpackage{everyshi}
% package would help, but this package should not require other packages.
% The \xpackage{pageslts} package does a better handling, but requires
% some other packages.\\
% We will make a mistake here at most once:
%
% \begin{macrocode}
\ifx \lastpage@firstpage\lastpage@one
\def\Hy@temp{\thepage}%
\gdef\lastpage@firstpage{0}%
\else%
%% Code from hyperref package again: %%
\pdfstringdef\Hy@temp{\thepage}%
%% End of code from the hyperref package. %%
\fi%
%% The pageslts package would even check for fnsymbol page %%
%% numbering scheme and adapt the code correspondingly. %%
\else%
%% Code from hyperref package again: %%
\pdfstringdef\Hy@temp{\thepage}%
%% Code from pageslts package again: %%
\fi%
%% Code from hyperref package again: %%
\fi
\else
\def\Hy@temp{\the\Hy@pagecounter}%
\fi
\fi
\immediate\write\@auxout{%
\string\newlabel
{LastPage}{{}{\thepage}{}{%
\ifHy@pageanchor page.\Hy@temp\fi}{}}%
}%
%% End of code from the hyperref package. %%
% \end{macrocode}
%
% After the writeout we restore the page number again,
% since there might be other things still to be done.
%
% \begin{macrocode}
\addtocounter{page}{+1}%
\endgroup
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\AtEndDocument}
% \indent |\AtEndDocument| we again (re)define |\lastpage@putlabel|
% to do nothing.
%
% \begin{macrocode}
\AtEndDocument{%
\gdef\lastpage@putlabel{\relax}
% \end{macrocode}
%
% It is checked whether writing to files is allowed
% (otherwise, only an error message is issued and nothing is done).
%
% \begin{macrocode}
\if@filesw%
% \end{macrocode}
%
% We put in a |\message| to show, in what order things (which were called)
% are done (see subsection~\ref{ssec:aed}).
%
% \begin{macrocode}
\message{^^JAED: lastpage setting LastPage^^J}%
% \end{macrocode}
%
% After this we issue a |\clearpage| to put out all floats,
% which are still floatig, and place the \texttt{LastPage} label.
%
% \begin{macrocode}
\clearpage\lastpage@putl@bel%
% \end{macrocode}
%
% When writing to files is not allowed, only an error message is issued
% and nothing is done.
%
% \begin{macrocode}
\else%
\PackageError{lastpage}{No auxiliary file allowed}%
{The lastpage package was not allowed to write to an .aux file.\MessageBreak%
This package does not work without access to an .aux file.\MessageBreak%
Press Ctrl+Z to exit.\MessageBreak%
}%
\fi%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \pagebreak
%
% \section{Installation}
%
% \begin{center}
% {\large \textbf{First, please make sure that there is no old version of}}
% {\large \textbf{\textsf{lastpage}\ at some obsolete place in your system!}}
% \end{center}
%
% \subsection{Downloads\label{ss:Downloads}}
%
% Everything is available at \CTAN{}, \url{http://www.ctan.org/tex-archive/},
% but may need additional packages themselves.\\
%
% \DescribeMacro{lastpage.dtx}
% For unpacking the |lastpage.dtx| file and constructing the documentation it is required:
% \begin{description}
% \item[-] \TeX Format \LaTeXe{}: \url{http://www.CTAN.org/}
%
% \item[-] document class \xpackage{ltxdoc}, 2007/11/11, v2.0u,\\
% \CTAN{macros/latex/base/ltxdoc.dtx}
%
% \item[-] package \xpackage{holtxdoc}, 2011/02/04, v0.21,\\
% \CTAN{macros/latex/contrib/oberdiek/holtxdoc.dtx}
%
% \item[-] package \xpackage{hypdoc}, 2010/03/26, v1.9,\\
% \CTAN{macros/latex/contrib/oberdiek/hypdoc.dtx}
% \end{description}
%
% \DescribeMacro{lastpage.sty}
% The |lastpage.sty| for \LaTeXe\ (i.\,e. each document using
% the \xpackage{lastpage} package) requires:
% \begin{description}
% \item[-] \TeX Format \LaTeXe{}, \url{http://www.CTAN.org/}
%
% \item[-] package \xpackage{lastpage}, 2011/08/08, v1.2i,\\
% \CTAN{macros/latex/contrib/lastpage/lastpage.dtx}
% \end{description}
% and can use
% \begin{description}
% \item[-] package \xpackage{hyperref}, 2011/04/17, v6.82g,\\
% \CTAN{macros/latex/contrib/hyperref.zip}
% \end{description}
%
% \DescribeMacro{lastpage209.sty}
% The |lastpage209.sty| for \LaTeX2.09\ (i.\,e. each document using
% the \xpackage{lastpage209} package) requires:
% \begin{description}
% \item[-] \TeX Format \LaTeX{}, v2.09
%
% \item[-] package \xpackage{lastpage209}, 2011/08/08, v1.2i, included in\\
% \CTAN{macros/latex/contrib/lastpage/lastpage.dtx}%
% \end{description}
% and does not work with \xpackage{hyperref}, which needs \LaTeX2e{}.\\
%
% \DescribeMacro{lastpage-example.tex}
% The \texttt{lastpage-example.tex} requires the same file as all
% documents using the \xpackage{lastpage} package, i.\,e.
% \begin{description}
% \item[-] package \xpackage{lastpage}, 2011/08/08, v1.2i,\\
% \CTAN{macros/latex/contrib/lastpage/lastpage.dtx}\\
% (Well, it is the example file for this package, and because you are reading the
% documentation for the \xpackage{lastpage} package, it can be assumed that you already
% have some version of it -- is it the current one?)
% \end{description}
% and additionally:
% \begin{description}
% \item[-] class \xpackage{article}, 2007/10/19, v1.4h, from \xpackage{classes.dtx}:\\
% \CTAN{macros/latex/base/classes.dtx}
%
% \item[-] package \xpackage{showkeys}, 2007/08/07, v3.15,\\
% \CTAN{macros/latex/required/tools/showkeys.dtx}
%
% \item[-] package \xpackage{hyperref}, 2011/04/17, v6.82g,\\
% \CTAN{macros/latex/contrib/hyperref.zip}
% \end{description}
%
% \DescribeMacro{endfloat}
% The \xpackage{endfloat} package is not required, but because
% the \xpackage{lastpage} package is incompatibel with \textit{very} old versions
% of the \xpackage{endfloat} package (see subsection~\ref{sec:endfloat}),
% here the recent one is listed:
% \begin{description}
% \item[-] package \xpackage{endfloat}, 1995/10/11, v2.4i,\\
% \CTAN{macros/latex/contrib/endfloat/endfloat.dtx}
% \end{description}
%
% \DescribeMacro{fancyhdr}
% \DescribeMacro{nccfancyhdr}
% Neither the \xpackage{fancyhdr} nor the \xpackage{nccfancyhdr} package is required
% (older versions of the \xpackage{lastpage} package used its predecessor
% \xpackage{fancyheadings}), but because they were mentioned, also they are listed
% here:
% \begin{description}
% \item[-] package \xpackage{fancyhdr}, 2005/03/22, v3.2,\\
% \CTAN{macros/latex/contrib/fancyhdr.zip}
%
% \item[-] package \xpackage{nccfancyhdr}, 2004/12/07, v1.1,\\
% \CTAN{macros/latex/contrib/ncctools/source/nccfancyhdr.dtx}
% \end{description}
%
% \DescribeMacro{regstats}
% For counting the used couters (and other registers), the \xpackage{regstats}
% package was mentioned (it is not required). It can be found at:
% \begin{description}
% \item[-] package \xpackage{regstats}, 2011/06/18, v1.0d,\\
% \CTAN{macros/latex/contrib/regstats/regstats.dtx}
% \end{description}
%
% \DescribeMacro{count1to}
% \DescribeMacro{nofm}
% \DescribeMacro{totpages}
% \DescribeMacro{lastpage}
% \DescribeMacro{zref}
% As possible alternatives in section~\ref{sec:Alternatives}, Alternatives, there are listed
% \begin{description}
% \item[-] package \xpackage{pageslts}, 2011/08/08, v1.2a,\\
% \CTAN{macros/latex/contrib/pageslts/pageslts.dtx}
%
% \item[-] package \xpackage{papermas}, 2011/08/08, v1.0g; the \xpackage{papermas}
% package can be considered as kind of add-on to the \xpackage{pageslts} package.\\
% \CTAN{macros/latex/contrib/papermas/papermas.dtx}
%
% \item[-] package \xpackage{count1to}, 2009/05/24, v2.1,\\
% \CTAN{macros/latex/contrib/ms/count1to.dtx}
%
% \item[-] package \xpackage{nofm}, 1991/02/25, v?.?,\\
% \url{ftp://tug.ctan.org/pub/tex-archive/obsolete/macros/latex209/contrib/misc/nofm.sty},
% does not work with e.\,g. \xpackage{hyperref}
%
% \item[-] package \xpackage{totpages}, 2005/09/19, v2.00,\\
% \CTAN{macros/latex/contrib/totpages/totpages.dtx}
%
% \item[-] package \xpackage{zref}, 2011/03/18, v2.21,\\
% \CTAN{macros/latex/contrib/oberdiek/zref.dtx},
% requires $\varepsilon$-\TeX{}.
% \end{description}
%
% \DescribeMacro{Oberdiek}
% \DescribeMacro{holtxdoc}
% \DescribeMacro{zref}
% All packages of \textsc{Heiko Oberdiek's} bundle `oberdiek'
% (especially \xpackage{holtxdoc} and \xpackage{zref})
% are also available in a TDS compliant ZIP archive:\\
% \CTAN{install/macros/latex/contrib/oberdiek.tds.zip}.\\
% It is probably best to download and use this, because the packages in there
% are quite probably both recent and compatible among themselves.\\
%
% \DescribeMacro{hyperref}
% \noindent \xpackage{hyperref} is not included in that bundle and needs to be downloaded
% separately,\\
% \url{http://mirror.ctan.org/install/macros/latex/contrib/hyperref.tds.zip}.\\
%
% \DescribeMacro{M\"{u}nch}
% A hyperlinked list of my (other) packages can be found at
% \url{http://www.Uni-Bonn.de/~uzs5pv/LaTeX.html}.\\
%
% \subsection{Package, unpacking TDS}
%
% \paragraph{Package.} This package is available on \CTAN{}.
% \begin{description}
% \item[\CTAN{macros/latex/contrib/lastpage/lastpage.dtx}]\hspace*{0.1cm} \\
% The source file.
% \item[\CTAN{macros/latex/contrib/lastpage/lastpage.pdf}]\hspace*{0.1cm} \\
% The documentation.
% \item[\CTAN{macros/latex/contrib/lastpage/lastpage-example.pdf}]\hspace*{0.1cm} \\
% The compiled example file, as it should look like.
% \item[\CTAN{macros/latex/contrib/lastpage/README}]\hspace*{0.1cm} \\
% The README file.
% \end{description}
% There is also a \texttt{lastpage.tds.zip} available:
% \begin{description}
% \item[\CTAN{install/macros/latex/contrib/lastpage.tds.zip}]\hspace*{0.1cm} \\
% Everything in TDS compliant, compiled format.
% \end{description}
% which additionally contains\\
% \begin{tabular}{ll}
% lastpage.ins & The installation file.\\
% lastpage.drv & The driver to generate the documentation.\\
% lastpage.sty & The \xext{sty}le file.\\
% lastpage209.sty & The \xext{sty}le file for \LaTeX2.09\ \textbf{only}.\\
% lastpage-example.tex & The example file.%
% \end{tabular}
%
% \bigskip
%
% \noindent For required other packages, see the preceding subsection.
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip\ archive. The files are extracted by running the
% \xfile{.dtx} through \plainTeX:
% \begin{quote}
% \verb|tex lastpage.dtx|
% \end{quote}
%
% About generating the documentation see paragraph~\ref{GenDoc} below.\\
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree), \textbf{but first you should delete
% the old \xpackage{lastpage} files (which are probably located in other directories).}
% You can make a backup of the old files before deleting them, of course.
% \begin{quote}
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
% lastpage.sty & tex/latex/lastpage.sty\\
% lastpage.pdf & doc/latex/lastpage.pdf\\
% lastpage-example.tex & doc/latex/lastpage-example.tex\\
% lastpage-example.pdf & doc/latex/lastpage-example.pdf\\
% lastpage.dtx & source/latex/lastpage.dtx\\
% lastpage209.sty & tex/latex/lastpage209.sty for \LaTeX2.09\\
% \end{tabular}^^A
% }^^A
% \sbox0{\t}^^A
% \ifdim\wd0>\linewidth
% \begingroup
% \advance\linewidth by\leftmargin
% \advance\linewidth by\rightmargin
% \edef\x{\endgroup
% \def\noexpand\lw{\the\linewidth}^^A
% }\x
% \def\lwbox{^^A
% \leavevmode
% \hbox to \linewidth{^^A
% \kern-\leftmargin\relax
% \hss
% \usebox0
% \hss
% \kern-\rightmargin\relax
% }^^A
% }^^A
% \ifdim\wd0>\lw
% \sbox0{\small\t}^^A
% \ifdim\wd0>\linewidth
% \ifdim\wd0>\lw
% \sbox0{\footnotesize\t}^^A
% \ifdim\wd0>\linewidth
% \ifdim\wd0>\lw
% \sbox0{\scriptsize\t}^^A
% \ifdim\wd0>\linewidth
% \ifdim\wd0>\lw
% \sbox0{\tiny\t}^^A
% \ifdim\wd0>\linewidth
% \lwbox
% \else
% \usebox0
% \fi
% \else
% \lwbox
% \fi
% \else
% \usebox0
% \fi
% \else
% \lwbox
% \fi
% \else
% \usebox0
% \fi
% \else
% \lwbox
% \fi
% \else
% \usebox0
% \fi
% \else
% \lwbox
% \fi
% \else
% \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
% TDS installing feature, then some files can already be in the right
% place, see the documentation of \docstrip.
%
% \pagebreak
%
% \subsection{Refresh file name databases}
%
% If your \TeX~distribution (\teTeX, \mikTeX,\dots) relies on file name
% databases, you must refresh these. For example, \teTeX\ users run
% \verb|texhash| or \verb|mktexlsr|.
%
% \subsection{Some details for the interested}
%
% \paragraph{Unpacking with \LaTeX.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip\ and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX\ for \docstrip\ (really,
% \docstrip\ does not need \LaTeX), then inform the autodetect routine
% about your intention:
% \begin{quote}
% \verb|latex \let\install=y\input{lastpage.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.\label{GenDoc}}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by a
% configuration file \xfile{ltxdoc.cfg}. For instance, put the following
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
% \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
%
% \noindent An example follows how to generate the
% documentation with \pdfLaTeX :
%
% \begin{quote}
%\begin{verbatim}
%pdflatex lastpage.dtx
%makeindex -s gind.ist lastpage.idx
%pdflatex lastpage.dtx
%makeindex -s gind.ist lastpage.idx
%pdflatex lastpage.dtx
%\end{verbatim}
% \end{quote}
%
% \subsection{Compiling the example}
%
% The example file, \textsf{lastpage-example.tex}, can be compiled via\\
% \indent |latex lastpage-example.tex|\\
% or (recommended)\\
% \indent |pdflatex lastpage-example.tex|\\
% and will need at least two compiler runs to get all references right.
%
% \section{Acknowledgements}
%
% I (\textsc{H.-Martin M\"{u}nch}) would like to thank
% \textsc{Jeffrey P. Goldberg} (jeffrey+news at goldmark dot org) for
% inventing the \xpackage{lastpage} package as well as for granting me
% to update it. Further I would like to thank \textsc{Heiko Oberdiek}
% for providing a~lot~(!) of useful packages (from which I also got everything
% I know about creating a file in \xfile{dtx} format, ok, say it: copying),
% and the \Newsgroup{comp.text.tex} and \Newsgroup{de.comp.text.tex}
% newsgroups for their help in all things \TeX{}. Thanks for bug reports go
% to \textsc{Ulrike Fischer}, \textsc{Sebastian Bank}, and \textsc{James Hedges}.
% Thanks to \textsc{Sven Siegmund} for pointing out a necessary further
% explanation in the documentation.
%
% \pagebreak
%
% \phantomsection
% \begin{History}\label{History}
% \begin{Version}{1994/06/17 v0.99a}
% \item First shot by \textsc{Jeffrey P. Goldberg}.
% \end{Version}
% \begin{Version}{1994/06/25 v0.1b}
% \item Last version number created by \textsc{Jeffrey P. Goldberg}.
% \end{Version}
% \begin{Version}{1994/07/20 v0.1b (again)}
% \item Documentation updated by \textsc{Jeffrey P. Goldberg}.\\
% The main source code of the \xpackage{lastpage} package 1994/07/20,
% v0.1b, was:\\
% \begin{verbatim}
% \NeedsTeXFormat{LaTeX2e}[1994/06/01]
% \ProvidesPackage{lastpage}[1994/07/20 v0.1b
% LaTeX2e package for refs to last page number (JPG)]
% \def\lastpage@putlabel{\addtocounter{page}{-1}%
% \immediate\write\@auxout{\string
% \newlabel{LastPage}{{}{\thepage}}}%
% \addtocounter{page}{1}}
% \AtEndDocument{%
% \message{AED: lastpage setting LastPage}%
% \clearpage\lastpage@putlabel}%
% \endinput
% \end{verbatim}
% and then the \xpackage{hyperref} package and the \xpackage{revtex4}
% class even redefine\\
% |\lastpage@putlabel| (at least \xpackage{hyperref} version
% \sout{ 2010/09/13, v6.81n}\uwave{ 2011/04/17, v6.82g}, and
% REV\TeX{}4\ version 2010/07/25, v4.1r, still do this).
% \end{Version}
% \begin{Version}{2010/02/18 v1.1}
% \item Proposed |LastPages| label by \textsc{H.-Martin M\"{u}nch}
% on \Newsgroup{comp.text.tex}, see e.\,g.
% \url{http://groups.google.com/group/comp.text.tex/msg/4407493da9c747f0?dmode=source};
% now available in the \xpackage{pageslts} package.
% \end{Version}
% \begin{Version}{2010/07/29 v1.2a}
% \item Complete rewriting of the package; upgrade from \xpackage{fancyheadings}
% to \xpackage{fancyhdr} package, then removed the need for the
% \xpackage{fancyhdr} package at all.
% \item Included \textsf{lastpage209.sty} for \LaTeX2.09{}.
% \item Replacement of |\filedate|, |-version|, |-name|,\ldots\ because
% of \LaTeX{}~bug 2705:\\
% Synopsis: Possible problem with |\fileversion| and |\filedate|\\
% \url{http://www.latex-project.org/cgi-bin/ltxbugs2html?category=LaTeX&responsible=anyone&state=anything&keyword=lastpage&pr=latex%2F2705&search=}
% \item Example |lastpage-example.tex|.
% \item Alternatives listing (section \ref{sec:Alternatives}).
% \item Listing of \TeX\ sources (subsection \ref{ss:Downloads}).
% \item A~lot~(!) of details.
% \item Complete rewriting of the documentation.
% \item Added a list of my other packages.
% \item Everything in \texttt{DTX} framework.
% \item Included a |\CheckSum|.
% \item Complete rewriting of the README file.
% \end{Version}
% \begin{Version}{2010/08/12 v1.2b}
% \item Bug fix: |\@PackageInfoNoLine| is only available,
% if the \xpackage{hyperref} package is loaded.
% (Bug reported by \textsc{Ulrike Fischer}, thanks!)
% \item Detected another bug: |\ifHy@pageanchor| etc. do not work without
% \xpackage{hyperref}, and |\else| related to |\ifHy@pageanchor| was
% wrongly associated with a preceding |\if|, and everything went wrong.
% Now everything should work without \xpackage{hyperref} again.
% \item Renamed |\lastpage@putlabel| to |\lastpage@putl@bel| to get rid of
% the conflicts with other classes and packages and resulting
% multiple definitions of \texttt{lastpage} label.
% \end{Version}
% \begin{Version}{2010/08/23 v1.2c}
% \item Bug fix: Additionally to checking for the \xpackage{hyperref} package
% |\AtBeginDocument|, when placing the \texttt{lastpage} label it is also
% checked for the |\hyperref| command, in case \xpackage{hyperref} was not
% loaded at |\begin{document}| yet. (Bug reported by \textsc{Sebastian Bank},
% thanks!)
% \item Changed the |\unit| definition (got rid of an old |\rm|).
% \item Changed |\lastpage@puthyperlabel| to |\lastpage@putlabelhyper| analogous to
% |\pagesLTS@putlabelhyper| of the \xpackage{pageslts} package.
% \item The recent version of the Adobe Reader\ \sout{is}\uwave{was}\ 9.3.3
% (instead of 9.3.1).
% \item Updated version number and date of \xpackage{pagesLTS} package (especially
% for the check for outdated versions).
% \item Removed wrong \%\ from the driver file.
% \end{Version}
% \begin{Version}{2010/08/25 v1.2d}
% \item Bug fix: also \xpackage{tcilatex} defines the |\hyperref| command,
% therefore for \xpackage{hyperref} package detection this had to be
% changed to |\Hy@Warning|.
% \end{Version}
% \begin{Version}{2010/09/12 v1.2e}
% \item \textsc{James Hedges} (Thanks!) pointed out, that there was no
% instruction in the documentation about suppressing hyperlinks:
% added (also to the example).
% \item The recent version of the Adobe Reader\ \sout{is}\uwave{was}\ 9.3.4
% (instead of 9.3.3).
% \item Diverse small changes.
% \end{Version}
% \begin{Version}{2010/09/24 v1.2f}
% \item Updated to version 2010/09/13 v6.81n of the \xpackage{hyperref} package.
% \item New version of REV\TeX{}4\ 2010/07/25, v4.1r, old problem.
% \item New version of \xpackage{pagesLTS} package, 2010/09/22, v1.1k.
% \item Moved the package from \texttt{.../latex/muench/lastpage/...} to\\
% \texttt{.../latex/lastpage/...}.\\
% (Please make sure that any old versions of the \xpackage{lastpage}
% package are properly uninstalled from your system.)
% \end{Version}
% \begin{Version}{2011/02/01 v1.2g}
% \item Updated to version 2010/04/24 v0.19 of the \xpackage{holtxdoc} package.
% \item New version of \xpackage{pagesLTS} package, 2011/02/01, v1.1m.
% \item Replaced the list of my packages with a link to a web page list of those,
% which has the advantage of showing the recent versions of all those packages.
% \item Updated to version 2010/12/16 v6.81z of the \xpackage{hyperref} package.
% \item The recent version of the Adobe Reader\ \sout{is}\uwave{was}\ X~(10.0.0)
% (instead of 9.3.4). Its handling of special page numbers was improved.
% \item Minor details.
% \end{Version}
% \begin{Version}{2011/07/03 v1.2h}
% \item The \xpackage{holtxdoc} package was fixed (recent: 2011/02/04, v0.21),
% therefore the warning in \xfile{drv} could be removed.~-- Adapted
% the style of this documentation to new \textsc{Oberdiek} \xfile{dtx}
% style.
% \item New version of \xpackage{pagesLTS} package, 2011/03/17, v1.1o.
% \item New version of \xpackage{ulem} package, 2011/03/18.
% \item There is a new version of the \xpackage{hyperref} package: 2011/04/17, v6.82g.
% \item There is a new version of the \xpackage{papermas} package: 2011/06/02, v1.0f .
% \item The recent version of the Adobe Reader is X (10.1.0; instead of 10.0.0).
% \item Corrected a reference to \xpackage{lastpage} at \CTAN{}.
% \item Corrected a reference to \xpackage{pagesLTS} at \CTAN{}.
% \item Corrected references in the README.
% \end{Version}
% \begin{Version}{2011/08/08 v1.2i}
% \item The \xpackage{pagesLTS} package has been renamed to \xpackage{pageslts}:
% 2011/08/08, v1.2a.
% \item Some details.
% \end{Version}
% \end{History}
%
% \bigskip
%
% When you find a mistake or have a suggestion for an improvement of this package,
% please send an e-mail to the maintainer, thanks! (Please see BUG REPORTS in the README.)
%
% \pagebreak
%
% \PrintIndex
%
% \Finale
\endinput
|