summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/pageslts/pagesLTS.sty
blob: 71fb920792fd2ca9ac890b0d554668076213fc08 (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
%%
%% This is file `pagesLTS.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pagesLTS.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% IMPORTANT NOTICE:
%% On the first page backslash pagenumbering should be called
%% (with the appropriate argument out of e.g.
%%  * roman - Lowercase Roman numerals: i, ii, iii, iv,...
%%  * Roman - Uppercase Roman numerals: I, II, III, IV,...
%%  * arabic - Arabic numerals: 1, 2, 3, 4,...
%%  * alph - Lowercase letters: a, b, c, d,...
%%  * Alph - Uppercase letters: A, B, C, D,...
%%  * fnsymbol - Footnote symbols: *, ^^86 (ddagger), ^^87 (dddagger),
%%                                 ^^a7 (mathsection),...
%% ). The command backslash pagenumbering is renewed, but no change
%% should be visible to the output text, because only labels are added.
%% backslash OrigPagenumbering can be used to get the original meaning
%% of backslash pagenumbering, but in that case this package does not
%% see the change in the page numbering scheme and will make mistakes.
%% The package takes options.
%% 
%% The usual disclaimers apply:
%% 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
%% (Martin dot Muench at Uni-Bonn dot de).
%% 
%% This package first started as a revision of the lastpage
%% package of Jeffrey P. Goldberg (jeffrey+news at goldmark dot org),
%% but it became obviouse that a replacement was needed.
%% 
%% This work consists of the main source file pagesLTS.dtx
%% and the derived files
%%    pagesLTS.sty, pagesLTS.pdf, pagesLTS.ins, pagesLTS.drv,
%%    pagesLTS-example.tex.
%% 
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{pagesLTS}[2010/06/24 v1.1c
            Refers to special pages' numbers/names (HMM)]%

%% Allow for things like\\
%% |Page \thepage\ (\theCurrentPage; local: \theCurrentPageLocal) of %
%%  \lastpageref{pagesLTS.roman}(\lastpageref{pagesLTS.roman.local}) + %
%%  \lastpageref{pagesLTS.Roman}(\lastpageref{pagesLTS.Roman.local}) + %
%%  \lastpageref{pagesLTS.arabic}(\lastpageref{pagesLTS.arabic.local}) + %
%%  \lastpageref{pagesLTS.fnsymbol}(\lastpageref{pagesLTS.fnsymbol.local}) + %
%%  \lastpageref{pagesLTS.alph}(\lastpageref{pagesLTS.alph.local}) + %
%%  \lastpageref{pagesLTS.Alph}(\lastpageref{pagesLTS.Alph.local}) = %
%%  \lastpageref{LastPages} pages.|\\
%% to get\\
%% 'Page d (57; local: 4) of ii(2) + XX(20) + *(1) + 30(30) + e(5) + C(3) = 61 pages.'.

\RequirePackage{atveryend}[2010/03/24]% v1.5
\RequirePackage{everyshi}[2001/05/15]%v 3.00
\RequirePackage{kvoptions}[2010/02/22]% v3.7
\RequirePackage{undolabl}[2010/06/24]% v1.0c
%% pagesLTS package uses Prelim@EveryShipout code from the
%% prelim2e package [2009/05/29 v1.3] by Martin Schr\"{o}der, thanks!

%% pagesLTS may work with earlier versions of those packages,
%% but this was not tested. Please consider updating your packages
%% to the most recent version (if they are not already the most
%% recent version).

%% The recent version of the endfloat package is v2.4i as of 1995/10/11.
%% The pagesLTS package is not fully compatible with version 2.0
%% (and earlier) of the endfloat package, because those versions
%% redefined the \enddocument command.

\SetupKeyvalOptions{family = pagesLTS,prefix = pagesLTS@}
\DeclareBoolOption[true]{pagecontinue} % \pagesLTS@pagecontinue
\DeclareStringOption{alphMult}[ab]
\DeclareStringOption{AlphMulti}[AB]
\DeclareBoolOption[true]{romanMult}
\DeclareBoolOption[true]{RomanMulti}
\DeclareBoolOption[true]{fnsymbolmult}

\ProcessKeyvalOptions*

\def\pagesLTS@zero{0}
\def\pagesLTS@one{1}

\ifpagesLTS@pagecontinue%
\PackageInfo{pagesLTS}{Option pagecontinue enabled\MessageBreak%
  (maybe by default):\MessageBreak%
  The pagesLTS package will continue the page numbering,\MessageBreak%
  when the same page numbering scheme is used twice.\MessageBreak%
  If you do not want this, call pagesLTS with option\MessageBreak%
  pagecontinue=false\MessageBreak%
  (or use \ setcounter{page}=1).\MessageBreak%
}%
\else%
\PackageWarningNoLine{pagesLTS}{Option pagecontinue is false:\MessageBreak%
  The pagesLTS package was used, but the option\MessageBreak%
  pagecontinue was set to false.\MessageBreak%
  If you want the page numbers to be continued,\MessageBreak%
  when the same page numbering scheme is used twice,\MessageBreak%
  please call pagesLTS with option pagecontinue=true,\MessageBreak%
  otherwise the page number is reset to one each time\MessageBreak%
  the page numbering scheme is changed.\MessageBreak%
  For details please see the documentation!\MessageBreak%
}%
\fi%

\def\pagesLTS@ab{ab}
\def\pagesLTS@bb{bb}
\def\pagesLTS@ABi{AB}
\def\pagesLTS@BBi{BB}
\def\pagesLTS@messageaMz{Option alphMult=0 found:\MessageBreak%
  The pagesLTS package was used, but the option\MessageBreak%
  alphMult was set to 0 (zero).\MessageBreak%
  If you want the page numbers to be extended\MessageBreak%
  after z, you have to organize this yourself now.\MessageBreak%
  For automatic continuation, please use the\MessageBreak%
  alphalph package and call pagesLTS\MessageBreak%
  with option alphMult=ab (for aa, ab, ac, ad,...) or\MessageBreak%
  with option alphMult=bb (for aa, bb, cc, dd,...).\MessageBreak%
  For details please see the documentation!\MessageBreak%
}
\def\pagesLTS@messageAMiz{Option AlphMulti=0 found:\MessageBreak%
  The pagesLTS package was used, but the option\MessageBreak%
  AlphMulti was set to 0 (zero).\MessageBreak%
  If you want the page numbers to be extended\MessageBreak%
  after Z, you have to organize this yourself now.\MessageBreak%
  For automatic continuation, please use the\MessageBreak%
  alphalph package and call pagesLTS\MessageBreak%
  with option AlphMulti=AB (for AA, AB, AC, AD,...) or\MessageBreak%
  with option AlphMulti=BB (for AA, BB, CC, DD,...).\MessageBreak%
  For details please see the documentation!\MessageBreak%
}
\def\pagesLTS@messagefsmz{Option fnsymbolmult is set to false:\MessageBreak%
  The pagesLTS package was used, but the option\MessageBreak%
  fnsymbolmult was set to false.\MessageBreak%
  If you want the page numbering of the footnotesymbol\MessageBreak%
  scheme to be extended using the AlphAlph package,\MessageBreak%
  please call pagesLTS with option fnsymbolmult=true,\MessageBreak%
  otherwise page numbers of the footnotesymbol scheme\MessageBreak%
  greater than nine will need to be defined otherwise.\MessageBreak%
  For details please see the documentation!\MessageBreak%
}

\ifx\pagesLTS@alphMult\pagesLTS@ab%
  \relax%
\else%
  \ifx\pagesLTS@alphMult\pagesLTS@bb%
    \relax%
  \else%
    \ifx\pagesLTS@alphMult\pagesLTS@zero%
      \PackageWarningNoLine{pagesLTS}{\pagesLTS@messageaMz }%
    \else%
      \PackageError{pagesLTS}{Unknown option value}%
        {The pagesLTS package was used with option\MessageBreak%
         alphMult= \pagesLTS@alphMult . Only values\MessageBreak%
         ab, bb, and 0 (zero) are valid.\MessageBreak%
         The default ab is set.\MessageBreak%
         For details please see the documentation!\MessageBreak%
        }%
      \setkeys{pagesLTS}{alphMult=ab}%
    \fi%
  \fi%
\fi%

\ifx\pagesLTS@AlphMulti\pagesLTS@ABi%
  \relax%
\else%
  \ifx\pagesLTS@AlphMulti\pagesLTS@BBi%
    \relax%
  \else%
    \ifx\pagesLTS@AlphMulti\pagesLTS@zero%
      \PackageWarningNoLine{pagesLTS}{\pagesLTS@messageAMiz }%
    \else%
      \PackageError{pagesLTS}{Unknown option value}%
        {The pagesLTS package was used with option\MessageBreak%
         AlphMulti= \pagesLTS@AlphMulti . Only values\MessageBreak%
         AB, BB, and 0 (zero) are valid.\MessageBreak%
         The default AB is set.\MessageBreak%
         For details please see the documentation!\MessageBreak%
        }%
      \setkeys{pagesLTS}{AlphMulti=AB}%
    \fi%
  \fi%
\fi%

\ifpagesLTS@romanMult%
  \PackageInfo{pagesLTS}{Option romanMult enabled\MessageBreak%
    (maybe by default):\MessageBreak%
    The pagesLTS package will extend the page numbering\MessageBreak%
    of the roman scheme below i with\MessageBreak%
     0, -i, -ii, -iii, -iv,...\MessageBreak%
    If you do not want this, call pagesLTS with option\MessageBreak%
    romanMult=false.\MessageBreak%
  }%
\else%
  \PackageWarningNoLine{pagesLTS}{Option romanMult is set to false:\MessageBreak%
  The pagesLTS package was used, but the option\MessageBreak%
  romanMult was set to false.\MessageBreak%
  If you want the page numbering of the roman scheme\MessageBreak%
  to be extended below i,\MessageBreak%
  please call pagesLTS with option romanMult=true,\MessageBreak%
  otherwise zero and negative page numbers of the\MessageBreak%
  roman scheme will need to be defined otherwise.\MessageBreak%
  For details please see the documentation!\MessageBreak%
  }%
\fi%

\ifpagesLTS@RomanMulti%
  \PackageInfo{pagesLTS}{Option RomanMulti enabled\MessageBreak%
    (maybe by default):\MessageBreak%
    The pagesLTS package will extend the page numbering\MessageBreak%
    of the Roman scheme below I with\MessageBreak%
    0, -I, -II, -III, -IV,...\MessageBreak%
    If you do not want this, call pagesLTS with option\MessageBreak%
    RomanMulti=false.\MessageBreak%
  }%
\else%
  \PackageWarningNoLine{pagesLTS}{Option RomanMulti is set to false:\MessageBreak%
  The pagesLTS package was used, but the option\MessageBreak%
  RomanMulti was set to false.\MessageBreak%
  If you want the page numbering of the Roman scheme\MessageBreak%
  to be extended below i,\MessageBreak%
  please call pagesLTS with option RomanMulti=true,\MessageBreak%
  otherwise zero and negative page numbers of the\MessageBreak%
  Roman scheme will need to be defined otherwise.\MessageBreak%
  For details please see the documentation!\MessageBreak%
  }%
\fi%

\ifpagesLTS@fnsymbolmult%
  \PackageInfo{pagesLTS}{Option fnsymbolmult enabled\MessageBreak%
    (maybe by default):\MessageBreak%
    The pagesLTS package will extend the page numbering\MessageBreak%
    of the footnotesymbol scheme using the AlphAlph\MessageBreak%
    package.\MessageBreak%
    If you do not want this, call pagesLTS with option\MessageBreak%
    fnsymbolmult=false.\MessageBreak%
  }%
\else%
  \PackageWarningNoLine{pagesLTS}{\pagesLTS@messagefsmz }%
\fi%

\def\pagesLTS@pnc{0}
\def\pagesLTS@called{0}
\def\pagesLTS@fns{fnsymbol}
\def\pagesLTS@alph{alph}
\def\pagesLTS@Alph{Alph}
\def\pagesLTS@AlphAlph{0}
\def\pagesLTS@hyper{0}
\def\pagesLTS@rerun{0}
\def\pagesLTS@eso{0}
\def\pagesLTS@esov{0}
\def\lastpageref{\lastpagereftxt}
\def\pagesLTS@messageNPN{%
 The pagesLTS package was used, but\MessageBreak%
 \textbackslash pagenumbering\MessageBreak%
 was not called at the beginning of the document\MessageBreak%
 (maybe earlier or later).\MessageBreak%
 Please use \textbackslash pagenumbering\MessageBreak%
 (with an argument like arabic, roman, Roman,\MessageBreak%
 fnsymbol, alph, or Alph) at the beginning\MessageBreak%
 of your document! Otherwise your document\MessageBreak%
 will probably compile, but the pagesLTS\MessageBreak%
 package might not be able to get all labels\MessageBreak%
 for the references to the respective pages\MessageBreak%
 right.\MessageBreak%
 }

\let\OrigPagenumbering\pagenumbering

\newcounter{CurrentPage}
\setcounter{CurrentPage}{1}
\def\theCurrentPageLocal{\arabic{pagesLTS.current.local.\pagesLTS@pnc}}
\newcounter{pagesLTS.pagenr}
\newcounter{pagesLTS.fnsymbol}
\newcounter{pagesLTS.fnsymbol.local}
\newcounter{pagesLTS.fnsymbol.cont}
\newcounter{pagesLTS.double.0}
\newcounter{pagesLTS.current.local.0}
\setcounter{pagesLTS.current.local.0}{1}
\newcounter{pagesLTS.pnc.0}

\newcommand{\xroman}[1]{%
  \ifnum\value{#1}>0 %
    \roman{#1}%
  \else%
    \ifnum\value{#1}<0 %
      -\romannumeral\number-\arabic{#1}
    \else%
      0%
    \fi%
  \fi%
  }

\newcommand{\XXRoman}[1]{%
  \ifnum\value{#1}>0 %
    \Roman{#1}%
  \else%
    \ifnum\value{#1}<0 %
      -\expandafter\@slowromancap\romannumeral\number-\arabic{#1}@%
    \else%
      0%
    \fi%
  \fi%
  }

\newcommand{\lastpages}[2]{%
  \@ifundefined{c@pagesLTS.#1.#2.local.cnt}{%
    \newcounter{pagesLTS.#1.#2.local.cnt}}{\relax}%
  \arabic{pagesLTS.#1.#2.local.cnt}%
  }

\newcommand{\pagesLTS@ifcounter}[1]{%
  \@ifundefined{c@#1}{\newcounter{#1}}{\relax}%
  }

\newcommand{\pagesLTS@writelabel}[1]{%
  \addtocounter{page}{+1}%
  \pagesLTS@putlabel{pagesLTS.#1}{\thepage}
  \addtocounter{page}{-1}%
  \ifx\pagesLTS@pnc\pagesLTS@zero%
    \relax%
  \else%
    \addtocounter{page}{+1}%
    \pagesLTS@putlabel{pagesLTS.#1.local}{\theCurrentPageLocal}
    \addtocounter{page}{-1}%
  \fi%
  }


%% The following code is from Heiko Oberdiek [2010/04/18],     %%
%% expanding his alphalph package [2010/04/18] v2.3. (Thanks!) %%
\newcommand*{\erroralphalph}[2]{%
  \ifnum\value{#2}>0 %
    #1{\value{#2}}%
  \else
    \ifnum\value{#2}<0 %
      -#1{\expandafter\@gobble\the\value{#2}}%
    \else
      0%
    \fi
  \fi
  }
%% End of code from Heiko Oberdiek                             %%
%% Check and Error/Warning messages have been moved to         %%
%% \EveryShipout, because messages inside e. g. the \pageref   %%
%% command can cause trouble.                                  %%


\newcommand{\expandPagenumbering}[1]{%
  \let\Origthepage\thepage%
  \def\pagesLTS@tmpC{arabic}%
  \ifx\pagesLTS@pnc\pagesLTS@tmpC%
    \relax%
  \else%
    \def\pagesLTS@tmpC{roman}%
    \ifx\pagesLTS@pnc\pagesLTS@tmpC%
      \ifpagesLTS@romanMult%
        \renewcommand*{\thepage}{\xroman{page}}%
      \fi%
    \else%
      \def\pagesLTS@tmpC{Roman}%
      \ifx\pagesLTS@pnc\pagesLTS@tmpC%
        \ifpagesLTS@RomanMulti%
          \renewcommand*{\thepage}{\XXRoman{page}}%
        \fi%
      \else%
        \ifx\pagesLTS@pnc\pagesLTS@alph%
          \ifx\pagesLTS@alphMult\pagesLTS@ab%
            \renewcommand*{\thepage}{\erroralphalph{\alphalph}{page}}%
          \else \ifx\pagesLTS@alphMult\pagesLTS@bb%
                  \renewcommand*{\thepage}{\erroralphalph{\alphMult}{page}}%
                \fi%
          \fi%
        \else%
          \ifx\pagesLTS@pnc\pagesLTS@Alph%
            \ifx\pagesLTS@AlphMulti\pagesLTS@ABi%
              \renewcommand*{\thepage}{\erroralphalph{\AlphAlph}{page}}%
            \else \ifx\pagesLTS@AlphMulti\pagesLTS@BBi%
                    \renewcommand*{\thepage}{\erroralphalph{\AlphMult}{page}}%
                  \fi%
            \fi%
          \else%
            \ifx\pagesLTS@pnc\pagesLTS@fns%
              \ifpagesLTS@fnsymbolmult%
                \renewcommand*{\thepage}{\erroralphalph{\fnsymbolmult}{page}}%
              \fi%
            \else%
              \PackageError{pagesLTS}{unknown page numbering scheme}{%
                The pagesLTS package encountered the unknown\MessageBreak%
                page numbering scheme\MessageBreak%
                `#1'. \MessageBreak%
                If this is no typing mistake, it might work\MessageBreak%
                - or it might not work.\MessageBreak%
                \@ehc%
                }
            \fi%
          \fi%
        \fi%
      \fi%
    \fi%
  \fi%
  \let\pagesLTS@tmpC\undefined%
  }

\renewcommand{\pagenumbering}[1]{%
  \edef\pagesLTS@tmpA{#1}%
  \ifx\pagesLTS@pnc\pagesLTS@tmpA%
    \relax%
  \else%
    \ifnum \value{CurrentPage}>1%
      \addtocounter{page}{-1}%
      \addtocounter{pagesLTS.current.local.\pagesLTS@pnc}{-1}%
      \newcounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}%
      \setcounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
        \value{pagesLTS.current.local.\pagesLTS@pnc}}%
      \ifx\pagesLTS@pnc\pagesLTS@fns%
        \ifnum \value{pagesLTS.pnc.\pagesLTS@pnc}>1%
          \pagesLTS@ifcounter{pagesLTS.tmpa}%
          \setcounter{pagesLTS.tmpa}{\value{pagesLTS.pnc.\pagesLTS@pnc}}%
          \addtocounter{pagesLTS.tmpa}{-1}%
          \pagesLTS@ifcounter{pagesLTS.tmpb}%
          \addtocounter{pagesLTS.tmpb}{\value{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.tmpa}.local.count}}%
          \addtocounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
            -\value{pagesLTS.tmpb}}%
        \fi%
      \else%
        \pagesLTS@writelabel{\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}}%
        \ifnum \value{pagesLTS.pnc.\pagesLTS@pnc}<2%
          \pagesLTS@writelabel{\pagesLTS@pnc}%
        \else%
          \pagesLTS@ifcounter{pagesLTS.tmpa}%
          \setcounter{pagesLTS.tmpa}{\value{pagesLTS.pnc.\pagesLTS@pnc}}%
          \addtocounter{pagesLTS.tmpa}{-1}%
          \pagesLTS@ifcounter{pagesLTS.\pagesLTS@pnc.done}%
          \addtocounter{pagesLTS.\pagesLTS@pnc.done}{%
            \value{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.tmpa}.local.count}}%
          \addtocounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
            -\value{pagesLTS.\pagesLTS@pnc.done}}%
        \fi%
        \if@filesw%
          \immediate\write\@auxout{\string
            \pagesLTS@ifcounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.cnt}}%
        \fi%
        \edef\pagesLTS@tmpB{\arabic{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}}%
        \if@filesw%
          \immediate\write\@auxout{\string
            \setcounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.cnt}{\pagesLTS@tmpB}}%
        \fi%
      \fi%
      \setcounter{pagesLTS.double.\pagesLTS@pnc}{\value{page}}%
      \addtocounter{pagesLTS.current.local.\pagesLTS@pnc}{+1}%
      \addtocounter{page}{+1}%
      \global\edef\pagesLTS@pnc{#1}%
      \OrigPagenumbering{#1}%
      \expandPagenumbering{#1}
      \pagesLTS@ifcounter{pagesLTS.pnc.\pagesLTS@pnc}%
      \addtocounter{pagesLTS.pnc.\pagesLTS@pnc}{1}%
      \pagesLTS@ifcounter{pagesLTS.double.\pagesLTS@pnc}%
      \addtocounter{pagesLTS.double.\pagesLTS@pnc}{1}%
      \ifpagesLTS@pagecontinue%
        \setcounter{page}{\value{pagesLTS.double.\pagesLTS@pnc}}%
      \else%
        \setcounter{page}{1}%
      \fi%
      \pagesLTS@ifcounter{pagesLTS.current.local.\pagesLTS@pnc}%
      \ifnum \value{pagesLTS.double.\pagesLTS@pnc}=1%
        \setcounter{pagesLTS.current.local.\pagesLTS@pnc}{1}%
      \fi%
    \else%
      %% before the first page has shiped out
      \global\edef\pagesLTS@pnc{#1}%
      \countdef\c@page=0 \c@page=1
      \def\cl@page{}
      \global\c@page \@ne
      \global\def\thepage{\csname \expandafter @\pagesLTS@pnc \endcsname \c@page}%
      \expandPagenumbering{#1}
      \pagesLTS@ifcounter{pagesLTS.pnc.\pagesLTS@pnc}%
      \setcounter{pagesLTS.pnc.\pagesLTS@pnc}{1}%
      \pagesLTS@ifcounter{pagesLTS.double.\pagesLTS@pnc}%
      \setcounter{pagesLTS.double.\pagesLTS@pnc}{1}%
      \pagesLTS@ifcounter{pagesLTS.current.local.\pagesLTS@pnc}%
      \setcounter{pagesLTS.current.local.\pagesLTS@pnc}{1}%
    \fi%
    \gdef\pagesLTS@called{1}%
  \fi%
  \let\pagesLTS@tmpA\undefined%
  \let\pagesLTS@tmpB\undefined%
  }

\newcommand{\lastpagereftxt}[1]{%
  \def\pagesLTS@tmpA{#1}%
  \def\pagesLTS@tmpB{pagesLTS.fnsymbol.local}%
  \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
    \ifx\pagesLTS@hyper\pagesLTS@one%
      \href{\#pagesLTS.fnsymbol.local.\arabic{pagesLTS.fnsymbol.local}}%
        {\arabic{pagesLTS.fnsymbol.local}}%
    \else \arabic{pagesLTS.fnsymbol.local}%
    \fi%
  \else%
    \pageref{#1}%
  \fi%
  \let\pagesLTS@tmpA\undefined%
  \let\pagesLTS@tmpB\undefined%
  }

\newcommand{\lastpagerefend}[1]{%
  \def\pagesLTS@tmpA{#1}%
  \def\pagesLTS@tmpB{pagesLTS.fnsymbol.local}%
  \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
    \ifx\pagesLTS@hyper\pagesLTS@one%
      \href{\#pagesLTS.fnsymbol.local.\arabic{pagesLTS.fnsymbol.local}}%
        {\arabic{pagesLTS.fnsymbol.local}}%
    \else \arabic{pagesLTS.fnsymbol.local}%
    \fi%
  \else%
    \def\pagesLTS@tmpB{pagesLTS.fnsymbol}%
    \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
      \ifx\pagesLTS@hyper\pagesLTS@one%
        \href{\#pagesLTS.fnsymbol.local.\arabic{pagesLTS.fnsymbol.local}}%
          {\pagesLTS.lastpage}%
      \else \pageref{pagesLTS.fnsymbol}%
      \fi%
    \else%
      \def\pagesLTS@tmpB{LastPage}%
      \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
        \ifx\pagesLTS@hyper\pagesLTS@one%
          \href{\#pagesLTS.fnsymbol.local.\pagesLTS@eso}%
            {\pagesLTS.lastpage}%
        \else \pageref{LastPage}%
        \fi%
      \else%
        \def\pagesLTS@tmpB{VeryLastPage}%
        \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
          \ifx\pagesLTS@hyper\pagesLTS@one%
            \href{\#pagesLTS.fnsymbol.local.\arabic{pagesLTS.fnsymbol.local}}%
              {\pagesLTS.lastpage}%
          \else \pageref{VeryLastPage}%
          \fi%
        \else%
          \def\pagesLTS@tmpB{LastPages}%
          \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
            \ifx\pagesLTS@hyper\pagesLTS@one%
              \href{\#pagesLTS.fnsymbol.local.\arabic{pagesLTS.fnsymbol.local}}%
                {\arabic{pagesLTS.pagenr}}%
            \else \pageref{LastPages}%
            \fi%
          \else%
            \pageref{#1}%
          \fi%
        \fi%
      \fi%
    \fi%
  \fi%
  \let\pagesLTS@tmpA\undefined%
  \let\pagesLTS@tmpB\undefined%
  }

\newcommand{\@pagesLTS@Prelim@EveryShipout}{%
%% The following code is from the prelim2e package             %%
%% [2009/05/29 v1.3] by Martin Schr\"{o}der (Thanks!):         %%
  \bgroup
    \dimen\z@=\wd\@cclv
    \dimen\@ne=\ht\@cclv
    \dimen\tw@=\dp\@cclv
    \dimen\thr@@=\dimen1
    \advance\dimen\thr@@ by \dimen\tw@
    \global\setbox\@cclv\vbox to \dimen\thr@@{%
      \hb@xt@\dimen\z@{%
        \box\@cclv%
        \hss%
        }%
      \vbox to \z@{%
        \hb@xt@\dimen\z@{%
          \let\protect\relax
%% Code not from prelim2e package:                             %%
          \ifx\pagesLTS@pnc\pagesLTS@fns%
            \addtocounter{pagesLTS.fnsymbol.cont}{1}%
            \ifx\pagesLTS@hyper\pagesLTS@one%
              \phantomsection%
              \hypertarget{pagesLTS.fnsymbol.local.\arabic{pagesLTS.fnsymbol.cont}}{}%
            \fi%
            \ifnum \pagesLTS@esov=\pagesLTS@zero%
              \label{pagesLTS.fnsymbol}%
            \else%
              \overridelabel{pagesLTS.fnsymbol}%
            \fi%
          \else%
            \ifx\pagesLTS@hyper\pagesLTS@one%
              \phantomsection%
            \fi%
            \if@filesw%
              \overridelabel{pagesLTS.\pagesLTS@pnc}%
              \immediate\write\@auxout{\string
                \undonewlabel{pagesLTS.\pagesLTS@pnc.local}{\on@line}}%
            \fi%
            \addtocounter{page}{+1}
            \pagesLTS@putlabel{pagesLTS.\pagesLTS@pnc.local}{\theCurrentPageLocal}%
            \addtocounter{page}{-1}
          \fi%
%% Code from prelim2e package again:                           %%
        }%
        \vss%
      }%
      \vss%
    }%
    \wd\@cclv=\dimen\z@
    \ht\@cclv=\dimen\@ne
    \dp\@cclv=\dimen\tw@
  \egroup
%% End of code from the prelim2e package.                      %%
  }

\EveryShipout{%
  \ifnum\value{page}>0%
    \relax%
  \else
    \ifnum\value{page}=0%
      \PackageWarning{pagesLTS}{%
        Counter `page' is zero!\MessageBreak%
        If the page numbering scheme is not arabic\MessageBreak%
        and further not extended\MessageBreak%
        (see Page counter overflow in the pagesLTS\MessageBreak%
        documentation), without other measures\MessageBreak%
        this will lead to a counter overflow.\MessageBreak%
      }
    \else%
      \ifnum\value{page}<0%
        \PackageWarning{pagesLTS}{%
          Counter `page' is negative: `\the\value{page}'!\MessageBreak%
          If the page numbering scheme is not arabic\MessageBreak%
          and further not extended\MessageBreak%
          (see Page counter overflow in the pagesLTS\MessageBreak%
          documentation), without other measures\MessageBreak%
          this will lead to a counter overflow.\MessageBreak%
        }
      \else%
        \PackageError{pagesLTS}{%
          Counter `page' does not have a recognized value:\MessageBreak%
          `\the\value{page}'\MessageBreak%
          \@ehd \MessageBreak%
          }
      \fi%
    \fi%
  \fi%
  \ifnum \value{CurrentPage}=1% This is the first shipout!
    \ifx\pagesLTS@called\pagesLTS@zero
      \PackageError{pagesLTS}{pagenumbering missing}{\pagesLTS@messageNPN }%
      \newcounter{pagesLTS@tmpD}%
      \setcounter{pagesLTS@tmpD}{\value{page}}%
%% Code from Andres L\"{o}h, Universiteit Utrecht (NL)         %%
      \def\extract#1{\expandafter\extract@ #1\END}
      \def\extract@#1\csname @#2\endcsname#3\END{#2}
      \edef\pagesLTS@tmpQ{\extract\thepage}%
%% End of code from Andres L\"{o}h                             %%
      \let\pagesLTS@tmpP\pagesLTS@tmpQ%
      \def\pagesLTS@pnc{0}%
      \pagenumbering{\pagesLTS@tmpP}%
      \setcounter{page}{\value{pagesLTS@tmpD}}%
    \fi%
    \pagesLTS@writelabel{0}%
  \fi%
  \ifx\pagesLTS@pnc\pagesLTS@fns%
    \@pagesLTS@Prelim@EveryShipout%
    \gdef\pagesLTS@esov{\arabic{pagesLTS.fnsymbol.cont}}%
  \else%
    \ifnum \value{pagesLTS.pnc.\pagesLTS@pnc}>1%
      \@pagesLTS@Prelim@EveryShipout%
    \fi%
  \fi%
  \addtocounter{CurrentPage}{1}%
  \addtocounter{pagesLTS.current.local.\pagesLTS@pnc}{1}%
  }

\newcommand{\pagesLTS@putlabelhyper}[2]{%
  \ifHy@pageanchor \relax%
  \else%
    \PackageError{pagesLTS}{hyperref option pageanchor disabled}{%
      The \string\lastpageref{#1} link doesn't work\MessageBreak%
      using hyperref with disabled option `pageanchor'.\MessageBreak%
    }%
  \fi
%% The following code is from the hyperref package             %%
%% [2010/04/17 v6.80x; newer versions are available]           %%
%% by Heiko Oberdiek (Big Thanks!).                            %%
  \if@filesw
    \begingroup
      \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 modified from the hyperref package. %%
%% Without the modification, after the first shipout "PD1" is  %%
%% inserted each time |\pdfstringdef\Hy@temp{\thepage}| is     %%
%% executed (if |fnsymbol| is not used).                       %%
            \ifnum \value{CurrentPage}=1%
              \ifx\pagesLTS@pnc\pagesLTS@fns%
                \pdfstringdef\Hy@temp{\thepage}%
              \else%
                \def\Hy@temp{\thepage}%
              \fi%
            \else%
              \pdfstringdef\Hy@temp{\thepage}%
            \fi%
%% Code from hyperref package again:                           %%
          \fi
        \else
          \def\Hy@temp{\the\Hy@pagecounter}%
        \fi
      \fi
%% End of code from the hyperref package.                      %%
%% (The following four lines are modified                      %%
%%  from the hyperref package.)                                %%
      \immediate\write\@auxout{\string
        \newlabel{#1}{{}{#2}{}{\ifHy@pageanchor page.\Hy@temp\fi}{}}}%
    \endgroup%
  \fi%
  }

\newcommand{\pagesLTS@putlabel}[2]{%
  \addtocounter{page}{-1}%
  \ifx\pagesLTS@hyper\pagesLTS@one%
    \pagesLTS@putlabelhyper{#1}{#2}%
  \else%
    \if@filesw%
      \immediate\write\@auxout{\string
        \newlabel{#1}{{}{#2}}}%
    \fi%
  \fi%
  \addtocounter{page}{+1}%
  }

\newcommand{\pagesLTS@putlabels}{%
  \addtocounter{page}{-1}%
  \addtocounter{CurrentPage}{-1}%
  \addtocounter{pagesLTS.current.local.\pagesLTS@pnc}{-1}%
  \ifx\pagesLTS@pnc\pagesLTS@zero%
   \PackageWarning{pagesLTS}{No page numbering scheme found:\MessageBreak%
     \pagesLTS@messageNPN }%
  \else%
    \pagesLTS@writelabel{\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}}%
    \ifnum \value{pagesLTS.pnc.\pagesLTS@pnc}<2%
      \ifx\pagesLTS@pnc\pagesLTS@fns%
        \relax%
      \else%
        \pagesLTS@writelabel{\pagesLTS@pnc}%
      \fi%
    \fi%
  \fi%
  \addtocounter{page}{+1}%
  \pagesLTS@putlabel{LastPages}{\theCurrentPage}
  \addtocounter{CurrentPage}{1}%
  \addtocounter{pagesLTS.current.local.\pagesLTS@pnc}{1}%
  }

\AtBeginDocument{%
  \if@filesw \relax%
  \else%
    \PackageError{pagesLTS}{No auxiliary file allowed.}%
     {The pagesLTS 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%
     }%
    % \endinput
  \fi%
  \@ifpackageloaded{endfloat}%
   {\@ifpackagelater{endfloat}{1992/03/31}% April 1992 v2.0
    {\@ifpackagelater{endfloat}{1995/10/10}{% 1995/10/11 v2.4i
       \relax}%
     {\PackageWarningNoLine{pagesLTS}{Old endfloat package detected:\MessageBreak%
        There is a newer version of the endfloat package available.\MessageBreak%
        Please consider updating your version.\MessageBreak%
        The pagesLTS package might be incompatible with\MessageBreak%
        your current endfloat package.\MessageBreak%
      }%
     }%
     {\PackageError{pagesLTS}{Incompatible, very old endfloat package detected.}%
      {The very old version 2.0 (and earlier) of the\MessageBreak%
       endfloat package actually redefined the \ enddocument,\MessageBreak%
       and so interferred drastically with the LaTeX2e commands\MessageBreak%
       which make use of \ AtEndDocument.\MessageBreak%
       Newer versions of the endfloat package exists\MessageBreak%
       (at least: v2.4i as of 1995/10/11)\MessageBreak%
       in modern documentation form,\MessageBreak%
       which should be available from CTAN.\MessageBreak%
       Please update your endfloat package\MessageBreak%
       for use with the pagesLTS package.\MessageBreak %
      }%
     }%
    }%
   }{}%
  \@ifpackageloaded{lastpage}%
   {\PackageWarning{pagesLTS}{Incompatible package lastpage detected:\MessageBreak%
      Package pagesLTS was loaded, but also the old\MessageBreak%
      lastpage package.\MessageBreak%
      pagesLTS has all functionality of the lastpage\MessageBreak%
      package (and more), so just remove the lastpage\MessageBreak%
      package from your document.\MessageBreak%
      pagesLTS will now ''kill'' the lastpage@putlabel\MessageBreak%
      command of the lastpage package.\MessageBreak%
    }%
    \gdef\lastpage@putlabel{\relax}%
   }{}%
  \@ifpackageloaded{alphalph}%
    {\PackageInfo{pagesLTS}{Package AlphAlph detected.\MessageBreak%
       pagesLTS supports alphalph. Congratulations!\MessageBreak%
       }%
     \global\def\pagesLTS@AlphAlph{1}%
     \newalphalph{\AlphMult}[mult]{\@Alph}{26}%
     \newalphalph{\alphMult}[mult]{\@alph}{26}%
     \newalphalph{\fnsymbolmult}[mult]{\@fnsymbol}{5}%
    }%
    {\ifx\pagesLTS@alphMult\pagesLTS@zero%
       \PackageWarning{pagesLTS}{\pagesLTS@messageaMz }%
     \else%
       \PackageError{pagesLTS}{Package AlphAlph not loaded}%
         {Package AlphAlph was not loaded, but package pagesLTS\MessageBreak%
          was called without option alphMult=0 (zero).\MessageBreak%
          Either load package AlphAlph,\MessageBreak%
          or give option alphMult=0 (zero) to the pagesLTS package.\MessageBreak%
         }%
     \fi%
     \ifx\pagesLTS@AlphMulti\pagesLTS@zero%
       \PackageWarning{pagesLTS}{\pagesLTS@messageAMiz }%
       \relax%
     \else%
       \PackageError{pagesLTS}{Package AlphAlph not loaded}%
         {Package AlphAlph was not loaded, but package pagesLTS\MessageBreak%
          was called without option AlphMulti=0 (zero).\MessageBreak%
          Either load package AlphAlph,\MessageBreak%
          or give option AlphMulti=0 (zero) to the pagesLTS package.\MessageBreak%
         }%
     \fi%
     \ifpagesLTS@fnsymbolmult%
       \PackageError{pagesLTS}{Package AlphAlph not loaded}%
         {Package AlphAlph was not loaded, but package pagesLTS\MessageBreak%
          was called without option fnsymbolmult=false.\MessageBreak%
          Either load package AlphAlph,\MessageBreak%
          or give option fnsymbolmult=false to the pagesLTS package.\MessageBreak%
         }%
     \else%
       \PackageWarning{pagesLTS}{\pagesLTS@messagefsmz }%
     \fi%
    }%
  \@ifpackageloaded{hyperref}%
    {\PackageInfo{pagesLTS}{Package hyperref detected.\MessageBreak%
       pagesLTS supports hyperref. Congratulations!\MessageBreak%
       }%
     \global\def\pagesLTS@hyper{1}%
     \@ifpackagelater{hyperref}{2010/06/03}{% 2010/06/04 v6.81f
       \relax}{%
       \PackageWarningNoLine{pagesLTS}{Old hyperref package detected:\MessageBreak%
         There is a newer version of the\MessageBreak%
         hyperref package available.\MessageBreak%
         Please consider updating your version.\MessageBreak%
       }%
     }%
     %% pagesLTS supports the use of the package hyperref by
     %% Heiko Oberdiek (hyperref version 2010/06/04 v6.81f).
     %% pagesLTS may work with earlier versions of this packages,
     %% but this was not tested.
    }%
    {\PackageWarning{pagesLTS}{Package hyperref NOT detected.\MessageBreak%
       pagesLTS would support hyperref. The page references\MessageBreak%
       will NOT be hyperlinked!\MessageBreak }%
    }%
  }

\AtEndDocument{%
  \message{AED: pagesLTS setting LastPage}%
  \clearpage%
  \ifx\pagesLTS@pnc\pagesLTS@fns%
    \def\pagesLTS@tmpA{\arabic{pagesLTS.fnsymbol.local}}%
    \ifnum \pagesLTS@eso=\pagesLTS@tmpA%
      \gdef\pagesLTS@rerun{0}%
    \else%
      \gdef\pagesLTS@rerun{1}%
    \fi%
    \if@filesw%
      \immediate\write\@auxout{\string
        \gdef\string\pagesLTS@eso{\pagesLTS@tmpA}}%
    \fi%
  \fi%
  \pagesLTS@putlabel{LastPage}{\thepage}%
  \let\pagesLTS@tmpA\undefined%
  }

\AfterLastShipout{%
  \if@filesw%
    \immediate\write\@auxout{\string
      \setcounter{pagesLTS.fnsymbol.local}{\pagesLTS@esov}}%
  \fi%
  \ifx\pagesLTS@hyper\pagesLTS@one%
    \ifx\pagesLTS@pnc\pagesLTS@fns%
      \if@filesw%
        \immediate\write\@auxout{\string
          \gdef\string\lastpageref{\string\lastpagerefend}}%
      \fi%
    \fi%
  \fi%
  \pagesLTS@ifcounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}%
  \setcounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
    \value{pagesLTS.current.local.\pagesLTS@pnc}}%
  \addtocounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{-1}
  \ifnum \value{pagesLTS.pnc.\pagesLTS@pnc}>1%
    \pagesLTS@ifcounter{pagesLTS.tmpA}%
    \setcounter{pagesLTS.tmpA}{\value{pagesLTS.pnc.\pagesLTS@pnc}}%
    \addtocounter{pagesLTS.tmpA}{-1}%
    \pagesLTS@ifcounter{pagesLTS.tmpB}%
    \addtocounter{pagesLTS.tmpB}{\value{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.tmpA}.local.count}}%
    \addtocounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
      -\value{pagesLTS.tmpB}}%
  \fi%
  \if@filesw%
    \immediate\write\@auxout{\string
      \pagesLTS@ifcounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.cnt}}%
    \edef\pagesLTS@tmpA{\arabic{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}}%
    \immediate\write\@auxout{\string
      \setcounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.cnt}{\pagesLTS@tmpA}}%
    \let\pagesLTS@tmpA\undefined%
  \fi%
  \addtocounter{page}{-1}%
  \edef\pagesLTS@tmpA{\thepage}%
  \if@filesw%
    \immediate\write\@auxout{\string
      \gdef\string\pagesLTS.lastpage{\pagesLTS@tmpA}}%
  \fi%
  \addtocounter{page}{+1}%
  \addtocounter{CurrentPage}{-1}%
  \def\pagesLTS@tmpB{\arabic{CurrentPage}}%
  \if@filesw%
    \immediate\write\@auxout{\string
      \setcounter{pagesLTS.pagenr}{\pagesLTS@tmpB}}%
  \fi%
  \addtocounter{CurrentPage}{+1}%
  \message{AED: pagesLTS setting VeryLastPage via AfterLastShipout}%
  \pagesLTS@putlabel{VeryLastPage}{\thepage}%
  \message{AED: pagesLTS setting LastPages via AfterLastShipout}%
  \pagesLTS@putlabels%
  \let\pagesLTS@tmpA\undefined%
  \let\pagesLTS@tmpB\undefined%
  }

\AtVeryEndDocument{%
  \ifx\pagesLTS@rerun\pagesLTS@one%
    \PackageWarningNoLine{pagesLTS}{Label(s) may have changed.\MessageBreak%
      Rerun to get cross-references right.\MessageBreak%
      }%
  \fi%
  }

\endinput
%%
%% End of file `pagesLTS.sty'.