%%
%% 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: 2023-03-07 v2.0a
%% Info: Refers to last page's name
%% 
%% Copyright (C) 2010 - 2023 by
%%     H.-Martin Muench <Martin dot Muench at Uni-Bonn dot de>
%% Portions of code copyrighted by other people as marked.
%% 
%% 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.
%% I thought that a replacement was needed and therefore created the pageslts package,
%% https://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.
%% 
%% While this package allows for things like "Page slash thepage{} of slash pageref{LastPage}"
%% to get "Page 7 of 9" or "Page VII of IX",
%% the NUMBER of pages is nowadays available via slash @abspage@last from the kernel,
%% but with pages for example I to X and then 1 to 10, the number of pages would be "20",
%% while the name of the last page is "10". Decide what you need/want!
%% 
%% This work consists of the main source file lastpage.dtx,
%% the README, and the derived files
%%    lastpage.sty, lastpage209.sty, lastpage2e.sty,
%%    lastpageclassic.sty, lastpagemodern.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}[2022/07/02]% v1.4n Standard LaTeX document class
\makeatletter
\@ifl@t@r\fmtversion{2022/11/01}{%
  \AddToHook{enddocument/afterlastpage}[lastpage]{%
         \message{^^JLaTeX Info: Executing hook `enddocument/afterlastpage'.}}%
}{\AtEndDocument{\message{^^JLaTeX Info: Executing hook `AtEndDocument'.}}%
 }
\makeatother
\usepackage[draft]{showkeys}[2022/04/12]% v3.18 Show cite and label keys (DPC, MH)
%%      Use final instead of draft to hide the keys. %%
\usepackage{hyperref}[2023-02-07]% v7.00v Hypertext links for LaTeX
\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},%
 pdfview=Fit,%
 pdfstartview=Fit,%
 pdfpagelayout=SinglePage%
}
%% If hyperref is not used, the url package
%%   https://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}[2023-03-07]% v2.0a
\makeatletter
\renewcommand{\@evenfoot}{%
 \normalsize\slshape \today\hfil \upshape %
 page \thepage{} of \pageref{LastPage}}
\renewcommand{\@oddfoot}{\@evenfoot}
\makeatother
\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}, v2.0a as of 2023-03-07 (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 Acrobat Reader 2022.003.20322:
Edit $>$ Preferences $>$ 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://ctan.org/pkg/pageslts}.
\bigskip

\noindent The page (\verb|\thepage|): \thepage \newline
Last page's name (LastPage): \pageref{LastPage}
\newpage

\noindent The page (\verb|\thepage|): \thepage \newline
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}|.
\newpage

\noindent The page (\verb|\thepage|): \thepage \newline
Last page's name (LastPage): \pageref{LastPage}
\bigskip

With modern \LaTeX{} it is possible to say:
\begin{quote}
\begin{verbatim}
\NeedsTeXFormat{LaTeX2e}[2022-11-01]
\documentclass{article}
\pagenumbering{fnsymbol}
\begin{document}
\addtocounter{page}{8}%
\makeatletter%
\ExplSyntaxOn%
\xdef\test{\numexpr\the\g_shipout_readonly_int +1\relax}%
\ExplSyntaxOff%
\ifnum \@abspage@last = \test\relax%
This is the last page.%
\else%
This is not the last page
(or it is but \LaTeX{} needs another compilation run
to detect this).
\fi
\makeatother
\end{document}
\end{verbatim}
\end{quote}

\newpage
\section*{The End}
\noindent The page (\verb|\thepage|): \thepage \newline
Last page's name (LastPage): \pageref{LastPage}
\bigskip

To see the content of the \texttt{enddocument/afterlastpage}-hook
(for a recent \LaTeX-format!) use
\verb|\ShowHook{enddocument/afterlastpage}|.% without the \verb||, of course!
\end{document}
\endinput
%%
%% End of file `lastpage-example.tex'.
