summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/lastpage/lastpage-example.tex
blob: a06abddb9f328828600dbeb3727961530f8be7d6 (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
%%
%% This is file `lastpage-example.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% lastpage.dtx  (with options: `example')
%% 
%% This is a generated file.
%% 
%% Project: lastpage
%% Version: 2021/09/03 v1.2n
%% 
%% Copyright (C) 2010 - 2021 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 applies:
%% 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
%%    https://www.latex-project.org/lppl/lppl-1-3c.txt
%% and the latest version of this license is in
%%    https://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 (jeffrey+news at goldmark dot org).
%% I thought that a replacement was needed and therefore created the pageslts package,
%% https://www.ctan.org/pkg/pageslts
%% . 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,
%% the README, and the derived files
%%    lastpage.sty, lastpage.pdf,
%%    lastpage.ins, lastpage.drv,
%%    lastpage-example.tex, lastpage-example.pdf.
%% 
%% In memoriam
%%  Claudia Simone Barth + 1996/01/30
%%  Tommy Muench + 2014/01/02
%%  Hans-Klaus Muench + 2014/08/24
%% 
\documentclass[british]{article}[2014/09/29]% v1.4h
\AtEndDocument{\message{^^JLaTeX Info: Executing hook `AtEndDocument'.}}
\usepackage[draft]{showkeys}[2014/10/28]% v3.17
%%      Use final instead of draft to hide the keys. %%
\usepackage{hyperref}[2012/11/06]% v6.83m
\hypersetup{%
 extension=pdf,%
 plainpages=false,%
 pdfpagelabels=true,%
 hyperindex=false,%
 pdflang={en},%
 pdftitle={lastpage package example},%
 pdfauthor={H.-Martin Muench},%
 pdfsubject={Example for the lastpage package},%
 pdfkeywords={LaTeX, lastpage, H.-Martin Muench},%
 pdfview=Fit,%
 pdfstartview=Fit,%
 pdfpagelayout=SinglePage%
}
%% If hyperref is not used, the url package
%%   https://www.ctan.org/pkg/url
%% must be loaded for the \url used in this example:
%% \usepackage{url}
%% or just use \let\url\texttt for the one used url.
\usepackage{lastpage}[2021/09/03]% v1.2n
\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.2n as of 2021/09/03 (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 (in Adobe Reader DC 2021.005.20060:
Edit $>$ Preferences $>$ Categories: Page Display $>$
Page Content and Information: Use logical page numbers)!\newline

If you are more ambitious in respect to your aims with this package,
you might want to have a look at the \textsf{pageslts} package:\newline
\url{https://www.ctan.org/pkg/pageslts}.

\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}

\bigskip

\noindent There was the question:

\begin{quote}
\begin{verbatim}
\documentclass{article}
\usepackage{hyperref}
\usepackage{lastpage}
\begin{document}
\ifnum\thepage=\pageref{LastPage} foo \else bar \fi
\end{document}
\end{verbatim}

producing the error
\textquotedblleft missing number, treated as zero\textquotedblright.
\end{quote}

\noindent \verb|\pageref| inserts a hyperlink, \verb|\pageref{LastPage}|
is not expandable and the code breaks.\newline
The code does not generally work even without hyperref.

\begin{quote}
\begin{verbatim}
\documentclass{article}
\usepackage{hyperref}
\usepackage{lastpage}
\pagenumbering{Roman}
\begin{document}
\addtocounter{page}{8}
\edef\here{\thepage}
\makeatletter
\ifx\here\lastpage@lastpage\relax foo \else bar \fi
\makeatother
\end{document}
\end{verbatim}
\end{quote}

\noindent does work, because \verb|\lastpage@lastpage| contains the name
of the page, example:\newline
\verb|Page \thepage{} is page \makeatletter\lastpage@lastpage\makeatother.|%
\newline
prints:\newline
Page \thepage{} is page \makeatletter\lastpage@lastpage\makeatother.%
\newline
This can be broken for example by \verb|\pagenumbering{fnsymbol}|.
\end{document}
\endinput
%%
%% End of file `lastpage-example.tex'.