%%
%% 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.
%% 
%% Project: pageslts
%% Version: 2025-01-10 v2.0d
%% Info: Variants of last page labels
%% 
%% Copyright (C) 2010 - 2025 by
%%     H.-Martin Muench <Martin dot Muench at Uni-Bonn dot de>
%% Portions of code copyrighted by other people as marked.
%% 
%% 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: *, ^^e2^^80^^a0 (ddagger), ^^e2^^80^^a1 (dddagger),
%%                                  ^^c2^^a7 (mathsection),...
%%  * silly    - from sillypage package
%%  * gobble   - gobbles the page numbers;
%%                maybe backslash thispagestyle{empty} is more useful?
%% ). 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.
%% 
%% 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 first started as a revision of the lastpage
%% package of Jeffrey P. Goldberg (jeffrey+news at goldmark dot org),
%% but I thought a replacement was needed.
%% 
%% This work consists of the main source file pageslts.dtx,
%% the README, and the derived files
%%    pageslts.sty, pageslts.pdf,
%%    pageslts.ins, pageslts.drv,
%%    pageslts-example.tex, pageslts-example.pdf.
%% 
%% In memoriam
%%  Claudia Simone Barth + 1996-01-30
%%  Tommy Muench         + 2014-01-02
%%  Hans-Klaus Muench    + 2014-08-24
%% 
\NeedsTeXFormat{LaTeX2e}[2024-11-01]
\ProvidesPackage{pageslts}[2025-01-10 v2.0d Refers to special pages' numbers/names (HMM)]

%% Allows for things like\par
%% |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.|\par
%% to get\par
%% 'Page d (57; local: 4) of ii(2) + XX(20) + *(1) + 30(30) + e(5) + C(3) = 61 pages.'.

\DeclareKeys[pagesLTS]
 {alphMult      .store = \pagesLTS@alphMult ,
  alphMult      .usage = preamble ,
  AlphMulti     .store = \pagesLTS@AlphMulti ,
  AlphMulti     .usage = preamble ,
  pagecontinue  .if    = pagesLTS@pagecontinue ,
  pagecontinue  .usage = load ,
  romanMult     .if    = pagesLTS@romanMult ,
  romanMult     .usage = load ,
  RomanMulti    .if    = pagesLTS@RomanMulti ,
  RomanMulti    .usage = load ,
  fnsymbolmult  .if    = pagesLTS@fnsymbolmult ,
  fnsymbolmult  .usage = load
 }

\SetKeys[pagesLTS]{alphMult=ab,AlphMulti=AB,pagecontinue=true,romanMult=true,RomanMulti=true,fnsymbolmult=true}

\DeclareUnknownKeyHandler[pagesLTS]{%
  \PackageError{pageslts}{Unknown option "\CurrentOption"}{%
    LaTeX has been asked to set an option called\MessageBreak%
    '#1' \if\relax\detokenize{#2}\relax\else with value '#2'\fi\MessageBreak%
    but the package "pageslts" has not created an option with this name.\MessageBreak%
    Try typing  <return>  to proceed.\MessageBreak%
    If that doesn't work, type  X <return>  to quit.%
   }%
  }

\ProcessKeyOptions[pagesLTS]

\@ifl@t@r\fmtversion{2024-11-01}{}{\PackageError{pageslts}{%
  LaTeX format 2024-11-01 or newer needed}{%
  Needed LaTeX format version: 2024-11-01 or newer.\MessageBreak%
  Found\space\space LaTeX format version: \fmtversion.\MessageBreak%
  Please update your TeX distribution!\MessageBreak%
  Loading of pageslts package is aborted.}
  \expandafter\endinput}

\RequirePackage{undolabl}[2024-12-05]
\IfPackageLoadedTF{undolabl}{\IfPackageAtLeastF{undolabl}{2024-12-05}{%
   \PackageError{pageslts}{undolabl package version too old}{%
     Required version: 2024-12-05 v1.0n or newer,\MessageBreak%
     found version:\space\space\space\space\csname ver@undolabl.sty\endcsname.%
}}}{\PackageError{pageslts}{undolabl package not loaded}{%
     The undolabl package is required by pageslts but was not loaded.}%
   }

\def\pagesLTS@zero{0}
\def\pagesLTS@one{1}
\def\pagesLTS@two{2}
\def\pagesLTS@three{3}
\def\pagesLTS@ab{ab}
\def\pagesLTS@bb{bb}
\def\pagesLTS@ABi{AB}
\def\pagesLTS@BBi{BB}

\ifpagesLTS@pagecontinue
  \PackageNoteNoLine{pageslts}{Option pagecontinue enabled (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 (or use \string\setcounter{page}=1)}
\else
  \PackageNoteNoLine{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}
\fi

\ifx\pagesLTS@alphMult\pagesLTS@ab%
\else
  \ifx\pagesLTS@alphMult\pagesLTS@bb%
  \else
    \ifx\pagesLTS@alphMult\pagesLTS@zero%
      \PackageNoteNoLine{pageslts}{%
        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,...)}
    \else
      \PackageError{pageslts}{Unknown option value}{%
        The pageslts package was used with option\MessageBreak%
        alphMult=\meaning\pagesLTS@alphMult .\MessageBreak%
        Only values 'ab', 'bb', and '0' (zero) are valid.\MessageBreak%
        Now the default 'ab' is being set.}
      \SetKeys[pagesLTS]{alphMult=ab}
    \fi
  \fi
\fi

\ifx\pagesLTS@AlphMulti\pagesLTS@ABi%
\else
  \ifx\pagesLTS@AlphMulti\pagesLTS@BBi%
  \else
    \ifx\pagesLTS@AlphMulti\pagesLTS@zero%
      \PackageNoteNoLine{pageslts}{%
        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,...)}
    \else
      \PackageError{pageslts}{Unknown option value}{%
        The pageslts package was used with option\MessageBreak%
        AlphMulti=\meaning\pagesLTS@AlphMulti .\MessageBreak%
        Only values 'AB', 'BB', and '0' (zero) are valid.\MessageBreak%
        The default 'AB' is set.}
      \SetKeys[pagesLTS]{AlphMulti=AB}
    \fi
  \fi
\fi

\ifx\pagesLTS@alphMult\pagesLTS@zero\else\RequirePackage{alphalph}[2019/12/09]\fi
\ifx\pagesLTS@AlphMulti\pagesLTS@zero\else\RequirePackage{alphalph}[2019/12/09]\fi
\ifpagesLTS@fnsymbolmult\RequirePackage{alphalph}[2019/12/09]\fi

\ifpagesLTS@romanMult
  \PackageNoteNoLine{pageslts}{Option romanMult enabled (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}
\else
  \PackageNoteNoLine{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}
\fi

\ifpagesLTS@RomanMulti
  \PackageNoteNoLine{pageslts}{Option RomanMulti enabled (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}
\else
  \PackageNoteNoLine{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}
\fi

\ifpagesLTS@fnsymbolmult
  \PackageNoteNoLine{pageslts}{Option fnsymbolmult enabled (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}
\else
  \PackageNoteNoLine{pageslts}{%
    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}
\fi

\def\pagesLTS@pnc{0}
\def\pagesLTS@called{0}
\def\pagesLTS@fns{fnsymbol}
\def\pagesLTS@alph{alph}
\def\pagesLTS@Alph{Alph}
\def\pagesLTS@gobble{gobble}
\def\pagesLTS@silly{silly}
\def\pagesLTS@rerun{0}
\def\pagesLTS@esoFs{0}
\def\pagesLTS@esovFs{0}
\def\pagesLTS@esoSy{0}
\def\pagesLTS@esovSy{0}
\def\pagesLTS@esoGbl{0}
\def\pagesLTS@esovGbl{0}
\def\lastpageref{\lastpagereftxt}
\def\pagesLTS@undolable{none}
\def\pncmissing{0}
\def\pagesLTS@messageNPN{%
 The pageslts package was used, but\MessageBreak%
 \string\pagenumbering \MessageBreak%
 was not called at the beginning of the document\MessageBreak%
 (maybe earlier or later).\MessageBreak%
 Please use \string\pagenumbering \MessageBreak%
 (with an argument like arabic, roman, Roman,\MessageBreak%
 fnsymbol, alph, Alph, gobble,\MessageBreak%
 or silly (requiring sillypage package))\MessageBreak%
 at the beginning of your document!\MessageBreak%
 Otherwise your document will probably compile,\MessageBreak%
 but the pageslts package might not be able\MessageBreak%
 to get all labels for the references\MessageBreak%
 to the respective pages right.\MessageBreak%
 }

\newcounter{CurrentPage}
\setcounter{CurrentPage}{1}
\def\theCurrentPageLocal{\arabic{pagesLTS.current.local.\pagesLTS@pnc}}
\newcounter{pagesLTS.pagenr}
\setcounter{pagesLTS.pagenr}{1}
\newcounter{pagesLTS.current.local.0}
\setcounter{pagesLTS.current.local.0}{1}
\newcounter{pagesLTS.pnc.0}
\newcounter{pagesLTS.tmpcounter}
\def\pagesLTSlastpage{1}
\def\pagesLTSlastpageHy{1}
\def\pagesLTS.lastpage{\pagesLTSlastpage}

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

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

\newcommand{\pagesLTS@providecounter}[1]{\@ifundefined{c@#1}{\newcounter{#1}}{}}
\NewCommandCopy{\pagesLTS@ifcounter}{\pagesLTS@providecounter}
\AddToHook{begindocument}{%
  \AddToHookWithArguments{cmd/pagesLTS@ifcounter/before}{%
    \PackageError{pageslts}{Old command \string\pagesLTS@ifcounter\space used}{%
      Replace by \string\pagesLTS@providecounter.}%
    }%
  }

\newcommand{\lastpages}[2]{%
  \pagesLTS@providecounter{pagesLTS.#1.#2.local.cnt}%
  \arabic{pagesLTS.#1.#2.local.cnt}%
  }

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


%% The following code is from Heiko Oberdiek [2010/04/18],                       %%
%% expanding his alphalph package as of 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 hook "shipout/foreground" %%
%% 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%
  \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%
        \IfPackageLoadedTF{romanbarpagenumber}{%
           \ifpagesLTS@RomanMulti%
             \renewcommand*{\thepage}{\Roman@bar{\XRoman{page}}}%
           \else%
             \renewcommand*{\thepage}{\Roman@bar{\Roman{page}}}%
           \fi%
         }{\ifpagesLTS@RomanMulti%
             \renewcommand*{\thepage}{\XRoman{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%
              \ifx\pagesLTS@pnc\pagesLTS@silly%
              \else%
                \ifx\pagesLTS@pnc\pagesLTS@gobble%
                  \IfPackageLoadedT{hyperref}{%
                    \renewcommand*{\thepage}{\texorpdfstring{\null}{{}}%
                      \csname @gobble\endcsname \c@page}}%
                \else%
                  \PackageError{pageslts}{unknown page numbering scheme}{%
                    The pageslts package encountered the unknown\MessageBreak%
                    page numbering scheme\MessageBreak%
                    \meaning#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\fi\fi%
  \let\pagesLTS@tmpC\undefined%
  }

\NewCommandCopy{\OrigPagenumbering}{\pagenumbering}

\renewcommand{\pagenumbering}[1]{%
  \edef\pagesLTS@tmpA{#1}%
  \ifx\pagesLTS@pnc\pagesLTS@tmpA%
  \else%
    \ifx\pagesLTS@tmpA\pagesLTS@fns%
      \pagesLTS@providecounter{pagesLTS.fnsymbol.local}%
    \fi%
    \ifx\pagesLTS@tmpA\pagesLTS@silly%
      \IfPackageLoadedF{sillypage}{\PackageError{pageslts}{%
        silly pagenumbering requested, sillypage package not loaded}{%
        When using \string\pagenumbering{silly},\MessageBreak%
        load the sillypage package.}}%
      \pagesLTS@providecounter{pagesLTS.silly.local}%
    \fi%
    \ifx\pagesLTS@tmpA\pagesLTS@gobble%
      \pagesLTS@providecounter{pagesLTS.gobble.local}%
    \fi%
    \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%
          \setcounter{pagesLTS.tmpcounter}{\numexpr\value{pagesLTS.pnc.\pagesLTS@pnc}-1\relax}%
          \addtocounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
            -\value{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.tmpcounter}.local.count}}%
        \fi%
      \else%
        \ifx\pagesLTS@pnc\pagesLTS@silly%
          \ifnum\value{pagesLTS.pnc.\pagesLTS@pnc}>1%
            \setcounter{pagesLTS.tmpcounter}{\numexpr\value{pagesLTS.pnc.\pagesLTS@pnc}-1\relax}%
            \addtocounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
              -\value{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.tmpcounter}.local.count}}%
          \fi%
        \else%
          \ifx\pagesLTS@pnc\pagesLTS@gobble%
            \ifnum\value{pagesLTS.pnc.\pagesLTS@pnc}>1%
              \setcounter{pagesLTS.tmpcounter}{\numexpr\value{pagesLTS.pnc.\pagesLTS@pnc}-1\relax}%
              \addtocounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
                -\value{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.tmpcounter}.local.count}}%
            \fi%
          \else%
            \ifnum\value{pagesLTS.pnc.\pagesLTS@pnc}<2%
              \pagesLTS@writelabel{\pagesLTS@pnc}%
            \fi%
          \fi%
        \fi%
        \ifnum\value{pagesLTS.pnc.\pagesLTS@pnc}>1%
          \ifpagesLTS@pagecontinue%
            \setcounter{pagesLTS.tmpcounter}{\numexpr\value{pagesLTS.pnc.\pagesLTS@pnc}-1\relax}%
            \pagesLTS@providecounter{pagesLTS.\pagesLTS@pnc.done}%
            \addtocounter{pagesLTS.\pagesLTS@pnc.done}{%
               \value{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.tmpcounter}.local.count}}%
            \addtocounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
               -\value{pagesLTS.\pagesLTS@pnc.done}}%
          \fi%
        \fi%
        \pagesLTS@writelabel{\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}}%
        \if@filesw%
          \immediate\write\@auxout{\string
            \pagesLTS@providecounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.cnt}}%
          \edef\pagesLTS@tmpB{\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@tmpB}}%
        \fi%
      \fi%
      \pagesLTS@providecounter{pagesLTS.double.\pagesLTS@pnc}%
      \setcounter{pagesLTS.double.\pagesLTS@pnc}{\value{page}}%
      \addtocounter{pagesLTS.current.local.\pagesLTS@pnc}{+1}%
      \addtocounter{page}{+1}%
      \xdef\pagesLTS@pnc{#1}%
      \ifpagesLTS@pagecontinue%
      \else%
        \pagesLTS@providecounter{pagesLTS.current.local.\pagesLTS@pnc}%
        \setcounter{pagesLTS.current.local.\pagesLTS@pnc}{1}%
      \fi%
      \OrigPagenumbering{#1}%
      \expandPagenumbering{#1}%
      \pagesLTS@providecounter{pagesLTS.pnc.\pagesLTS@pnc}%
      \addtocounter{pagesLTS.pnc.\pagesLTS@pnc}{1}%
      \pagesLTS@providecounter{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@providecounter{pagesLTS.current.local.\pagesLTS@pnc}%
      \ifnum\value{pagesLTS.double.\pagesLTS@pnc}=1%
        \setcounter{pagesLTS.current.local.\pagesLTS@pnc}{1}%
      \fi%
    \else%
      \ifx\pagesLTS@pnc\pagesLTS@zero\relax%
      \else%
        \PackageNoteNoLine{pageslts}{%
          \string\pagenumbering\space used more than once before the end\MessageBreak%
          of the first page, maybe in the preamble.\MessageBreak%
          Resetting all unused page numbering schemes now}%
        \setcounter{pagesLTS.pnc.\pagesLTS@pnc}{0}%
        \setcounter{pagesLTS.double.\pagesLTS@pnc}{0}%
        \setcounter{pagesLTS.current.local.\pagesLTS@pnc}{0}%
      \fi%
      \xdef\pagesLTS@pnc{#1}%
      \OrigPagenumbering{#1}%
      \expandPagenumbering{#1}%
      \pagesLTS@providecounter{pagesLTS.pnc.\pagesLTS@pnc}%
      \setcounter{pagesLTS.pnc.\pagesLTS@pnc}{1}%
      \pagesLTS@providecounter{pagesLTS.double.\pagesLTS@pnc}%
      \setcounter{pagesLTS.double.\pagesLTS@pnc}{1}%
      \pagesLTS@providecounter{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%
  }

%% analogous to \HyPsd@pageref from the hyperref package:
\def\lastpagereftxt#1{\pagesLTS@@pageref#1*\END}

\def\pagesLTS@@pageref#1*#2\END{%
  \ifx\\#2\\% no star
    \pagesLTS@@@pageref{#1}%
  \else% star
    \expandafter\pagesLTS@@@pagerefstar%
  \fi%
}

\def\pagesLTS@@@pageref#1{\lastpagereftext{#1}}
\def\pagesLTS@@@pagerefstar#1{\lastpagereftextstar{#1}}

\newcommand{\lastpagereftext}[1]{%
  \def\pagesLTS@tmpA{#1}%
  \def\pagesLTS@tmpB{pagesLTS.fnsymbol.local}%
  \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
    \pagesLTS@providecounter{pagesLTS.fnsymbol.local}%
    \IfPackageLoadedTF{hyperref}{%
      \href{\#pagesLTS.fnsymbol.local.\arabic{pagesLTS.fnsymbol.local}}%
        {\arabic{pagesLTS.fnsymbol.local}}%
     }{\arabic{pagesLTS.fnsymbol.local}}%
  \else%
    \def\pagesLTS@tmpB{pagesLTS.silly.local}%
    \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
      \pagesLTS@providecounter{pagesLTS.silly.local}%
      \IfPackageLoadedTF{hyperref}{%
        \href{\#pagesLTS.silly.local.\arabic{pagesLTS.silly.local}}%
          {\arabic{pagesLTS.silly.local}}%
       }{\arabic{pagesLTS.silly.local}}%
    \else%
      \def\pagesLTS@tmpB{pagesLTS.gobble.local}%
      \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
        \pagesLTS@providecounter{pagesLTS.gobble.local}%
        \IfPackageLoadedTF{hyperref}{%
          \href{\#pagesLTS.gobble.local.\arabic{pagesLTS.gobble.local}}%
            {\arabic{pagesLTS.gobble.local}}%
         }{\arabic{pagesLTS.gobble.local}}%
      \else%
        \pageref{#1}%
      \fi%
    \fi%
  \fi%
  \let\pagesLTS@tmpA\undefined%
  \let\pagesLTS@tmpB\undefined%
  }

\newcommand{\lastpagereftextstar}[1]{%
  \def\pagesLTS@tmpA{#1}%
  \def\pagesLTS@tmpB{pagesLTS.fnsymbol.local}%
  \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
     \pagesLTS@providecounter{pagesLTS.fnsymbol.local}%
     \arabic{pagesLTS.fnsymbol.local}%
  \else%
    \def\pagesLTS@tmpB{pagesLTS.silly.local}%
    \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
       \pagesLTS@providecounter{pagesLTS.silly.local}%
       \arabic{pagesLTS.silly.local}%
    \else%
      \def\pagesLTS@tmpB{pagesLTS.gobble.local}%
      \ifx\pagesLTS@tmpA\pagesLTS@tmpB%
         \pagesLTS@providecounter{pagesLTS.gobble.local}%
         \arabic{pagesLTS.gobble.local}%
      \else%
        \IfPackageLoadedTF{hyperref}{\pageref*{#1}}{\pageref{#1}}%
      \fi%
    \fi%
  \fi%
  \let\pagesLTS@tmpA\undefined%
  \let\pagesLTS@tmpB\undefined%
  }

\newcommand\overrideLTSlabel[2]{%
  \@bsphack%
  \if@filesw%
    \edef\pagesLTS@tmpC{#1}%
    \edef\pagesLTS@tmpD{pagesLTS.\pagesLTS@pnc.local}%
    \ifx\pagesLTS@tmpC\pagesLTS@tmpD%
      \ifnum\value{pagesLTS.pnc.\pagesLTS@pnc}>1%
        \immediate\write\@auxout{\string\undonewlabel{#1}}\@overriddenmessage s{#1}%
      \else%
        \edef\pagesLTS@tmpD{fnsymbol}%
        \ifx\pagesLTS@pnc\pagesLTS@tmpD%
          \immediate\write\@auxout{\string\undonewlabel{#1}}\@overriddenmessage s{#1}%
        \fi%
        \edef\pagesLTS@tmpD{gobble}%
        \ifx\pagesLTS@pnc\pagesLTS@tmpD%
          \immediate\write\@auxout{\string\undonewlabel{#1}}\@overriddenmessage s{#1}%
        \fi%
        \edef\pagesLTS@tmpD{silly}%
        \ifx\pagesLTS@pnc\pagesLTS@tmpD%
          \immediate\write\@auxout{\string\undonewlabel{#1}}\@overriddenmessage s{#1}%
        \fi%
      \fi%
    \fi%
    \pagesLTS@putlabel{#1}{#2}{0}%
  \fi%
  \@esphack%
  }

\newcommand{\pagesLTS@EveryShipout}{%
  \begingroup%
    \ifx\pagesLTS@pnc\pagesLTS@fns%
      \pagesLTS@providecounter{pagesLTS.fnsymbol.cont}%
      \addtocounter{pagesLTS.fnsymbol.cont}{1}%
      \IfPackageLoadedT{hyperref}{\phantomsection%
        \hypertarget{pagesLTS.fnsymbol.local.\arabic{pagesLTS.fnsymbol.cont}}{}%
        }%
      \ifnum\pagesLTS@esovFs=\pagesLTS@zero%
        \if@filesw\label{pagesLTS.fnsymbol}\fi%
        \pagesLTS@putlabel{pagesLTS.fnsymbol.local}{\theCurrentPageLocal}{0}%
      \else%
        \overridelabel{pagesLTS.fnsymbol}%
        \overrideLTSlabel{pagesLTS.fnsymbol.local}{\theCurrentPageLocal}%
      \fi%
    \else%
      \ifx\pagesLTS@pnc\pagesLTS@silly%
        \pagesLTS@providecounter{pagesLTS.silly.cont}%
        \addtocounter{pagesLTS.silly.cont}{1}%
        \IfPackageLoadedT{hyperref}{\phantomsection%
          \hypertarget{pagesLTS.silly.local.\arabic{pagesLTS.silly.cont}}{}%
          }%
        \ifnum\pagesLTS@esovSy=\pagesLTS@zero%
          \if@filesw\label{pagesLTS.silly}\fi%
          \pagesLTS@putlabel{pagesLTS.silly.local}{\theCurrentPageLocal}{0}%
        \else%
          \overridelabel{pagesLTS.silly}%
          \overrideLTSlabel{pagesLTS.silly.local}{\theCurrentPageLocal}%
        \fi%
      \else%
        \ifx\pagesLTS@pnc\pagesLTS@gobble%
          \pagesLTS@providecounter{pagesLTS.gobble.cont}%
          \addtocounter{pagesLTS.gobble.cont}{1}%
          \IfPackageLoadedT{hyperref}{\phantomsection%
            \hypertarget{pagesLTS.gobble.local.\arabic{pagesLTS.gobble.cont}}{}%
            }%
          \ifnum\pagesLTS@esovGbl=\pagesLTS@zero%
            \if@filesw\label{pagesLTS.gobble}\fi%
            \pagesLTS@putlabel{pagesLTS.gobble.local}{\theCurrentPageLocal}{0}%
          \else%
            \overridelabel{pagesLTS.gobble}%
            \overrideLTSlabel{pagesLTS.gobble.local}{\theCurrentPageLocal}%
          \fi%
        \else%
          \IfPackageLoadedT{hyperref}{\phantomsection}%
          \if@filesw%
            \overridelabel{pagesLTS.\pagesLTS@pnc}%
            \overrideLTSlabel{pagesLTS.\pagesLTS@pnc.local}{\theCurrentPageLocal}%
    \fi\fi\fi\fi%
  \endgroup%
  }

\AddToHook{shipout/foreground}{%
  \ifnum\value{page}>0%
  \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 has no recognized value}{%
          Counter `page' does not have a recognized value:\MessageBreak%
          `\the\value{page}'\MessageBreak%
          \@ehd\MessageBreak%
          }%
      \fi%
    \fi%
  \fi%
  \ifnum\value{CurrentPage}=1%
    \ifx\pagesLTS@called\pagesLTS@zero%
      \gdef\pncmissing{1}%
      \setcounter{pagesLTS.tmpcounter}{\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                     %%
      \def\pagesLTS@pnc{0}%
      \expandafter\pagenumbering\expandafter{\pagesLTS@tmpQ}%
      \setcounter{page}{\value{pagesLTS.tmpcounter}}%
    \fi%
    \pagesLTS@writelabel{0}%
  \fi%
  \ifx\pagesLTS@pnc\pagesLTS@fns%
    \pagesLTS@EveryShipout%
    \xdef\pagesLTS@esovFs{\arabic{pagesLTS.fnsymbol.cont}}%
  \else%
    \ifx\pagesLTS@pnc\pagesLTS@silly%
      \pagesLTS@EveryShipout%
      \xdef\pagesLTS@esovSy{\arabic{pagesLTS.silly.cont}}%
    \else%
      \ifx\pagesLTS@pnc\pagesLTS@gobble%
        \pagesLTS@EveryShipout%
        \xdef\pagesLTS@esovGbl{\arabic{pagesLTS.gobble.cont}}%
      \else%
        \ifnum\value{pagesLTS.pnc.\pagesLTS@pnc}>1%
          \pagesLTS@EveryShipout%
  \fi\fi\fi\fi%
  \addtocounter{CurrentPage}{1}%
  \addtocounter{pagesLTS.current.local.\pagesLTS@pnc}{1}%
  }

%% Code provided by Prof. Enrico Gregorio at https://tex.stackexchange.com/a/542425
\long\def\protected@iwrite#1#2#3{%
  \begingroup%
  #2%
  \let\protect\@unexpandable@protect%
  \edef\reserved@a{\immediate\write#1{#3}}%
  \reserved@a%
  \endgroup%
  \if@nobreak\ifvmode\nobreak\fi\fi%
  }

\newcommand{\pagesLTS@makeHy}{%
  \xdef\pagesLTS@Hptest{Doc-Start}%
  \ifx\pagesLTS@Hptest\@currentHpage\relax%
    \gdef\pagesLTS@Hy{\@currentHpage}%
  \else%
    \edef\pagesLTS@Hptest{\@currentHpage}%
    \ifx\pagesLTS@Hptest\empty\relax%
    \else%
      \edef\pagesLTS@Hptest{page.}%
      \ifx\@currentHpage\pagesLTS@Hptest\relax%
        \ifx\pagesLTS@pnc\pagesLTS@gobble%
          \PackageNoteNoLine{pageslts}{%
            With gobbled page numbers "\string\@currentHpage "\MessageBreak%
            is just "page." without number.\MessageBreak%
            "\string\pagesLTSlastpageHy " is now let empty}%
        \else%
          \PackageWarningNoLine{pageslts}{%
            \string\@currentHpage\space is just "page." without number.\MessageBreak%
            \string\pagesLTSlastpageHy\space is now let empty}%
        \fi%
      \else%
        \gdef\pagesLTS@Hy{\pagesLTS@rmpage{\@currentHpage}}%
        \ifx\pagesLTSlastpageHy\empty\relax%
          \PackageWarningNoLine{pageslts}{%
            \string\@currentHpage\space is\MessageBreak%
            \meaning\@currentHpage\MessageBreak%
            not beginning with "page.",\MessageBreak%
            \string\pagesLTSlastpageHy\space is now let empty}%
  \fi\fi\fi\fi%
  }%

%% Code provided by David Carlisle at https://tex.stackexchange.com/a/721877
\def\pagesLTS@rmpage#1{%
  \expandafter\xpagesLTS@rmpage\expanded{#1}\xpagesLTS@rmpage page.%
  \xpagesLTS@rmpage\xxpagesLTS@rmpage{#1}}
\def\xpagesLTS@rmpage #1page.#2\xpagesLTS@rmpage#3\xxpagesLTS@rmpage#4{%
  \if$\detokenize{#1}$#2%\else#4
  \fi}

\newcommand{\pagesLTS@putlabel}[3]{%
  \addtocounter{page}{-1}%
  \IfPackageLoadedT{showkeys}{%
    \IfPackageLoadedWithOptionsF{showkeys}{final}{%
      \ifnum\value{pagesLTS.pagenr}<1%
        \PackageWarningNoLine{pageslts}{%
          Package showkeys without option final loaded,\MessageBreak%
          but label #1 on page \thepage\space(about \theCurrentPage)\MessageBreak%
          cannot be shown, because pageslts does not use \string\label,\MessageBreak%
          but writes directly to the \jobname.aux file}%
      \else%
        \PackageWarningNoLine{pageslts}{%
          Package showkeys without option final loaded,\MessageBreak%
          but label #1 on page \thepage\space(about \theCurrentPage\space of \arabic{pagesLTS.pagenr})\MessageBreak%
          cannot be shown, because pageslts does not use \string\label,\MessageBreak%
          but writes directly to the \jobname.aux file}%
      \fi%
    }%
  }%
  \IfPackageLoadedTF{hyperref}{%
    \ifHy@pageanchor\else%
      \PackageWarningNoLine{pagesLTS}{%
        The \string\lastpageref{#1} link does not work\MessageBreak%
        using hyperref with disabled option `pageanchor'.\MessageBreak%
        Better enable `pageanchor' or use\MessageBreak%
        \string\lastpageref*{...} (not generating a link)%
      }%
    \fi%
    \if@filesw%
      \begingroup%
        \protected@iwrite\@auxout{}{\string\newlabel{#1}{%
          {\@currentlabel}{#2}{\@currentlabelname}%
          {\ifx\pagesLTS@pnc\pagesLTS@fns%
             \@currentHref%
           \else\ifx\pagesLTS@pnc\pagesLTS@silly%
             \@currentHref%
             \else\ifx\pagesLTS@pnc\pagesLTS@gobble%
               \@currentHref%
               \else\ifHy@pageanchor\@currentHpage\fi%
           \fi\fi\fi%
          }%
          {\@kernel@reserved@label@data}}}%
      \endgroup%
    \fi%
   }{%
    \if@filesw%
      \ifnum\value{pagesLTS.pnc.\pagesLTS@pnc}<2%
          \protected@iwrite\@auxout{}{\string\newlabel{#1}{%
            {\@currentlabel}{#2}{\@currentlabelname}%
            {\@currentHref}{\@kernel@reserved@label@data}}%
          }%
      \else%
        \edef\pagesLTS@tmpC{#1}%
        \edef\pagesLTS@tmpD{pagesLTS.\pagesLTS@pnc.local}%
        \ifx\pagesLTS@tmpC\pagesLTS@tmpD%
          \edef\pagesLTS@tmpC{#3}%
          \ifx\pagesLTS@tmpC\pagesLTS@one%
            \immediate\write\@auxout{\string\undonewlabel{#1}}%
          \fi%
        \fi%
        \protected@iwrite\@auxout{}{\string\newlabel{#1}{%
          {\@currentlabel}{#2}{\@currentlabelname}%
          {\@currentHref}{\@kernel@reserved@label@data}}%
        }%
      \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%
   \PackageWarningNoLine{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%
      \else\ifx\pagesLTS@pnc\pagesLTS@silly%
        \else\ifx\pagesLTS@pnc\pagesLTS@gobble%
          \else\pagesLTS@writelabel{\pagesLTS@pnc}%
  \fi\fi\fi\fi\fi%
  \addtocounter{page}{+1}%
  \pagesLTS@putlabel{LastPages}{\theCurrentPage}{1}%
  \addtocounter{CurrentPage}{+1}%
  \addtocounter{pagesLTS.current.local.\pagesLTS@pnc}{+1}%
  }

\AddToHook{begindocument/end}{%
  \IfPackageLoadedT{lastpage}{%
    \PackageNoteNoLine{pageslts}{Packages lastpage and pageslts used:\MessageBreak%
      Are you sure that you want to load both packages?}%
    }%
  \IfPackageLoadedTF{hyperref}{%
     \ProvideTextCommand{\textasteriskcentered}{PD1}{*}%
     \IfPackageAtLeastF{hyperref}{2024-11-05}{%
       \PackageError{pageslts}{hyperref package version too old}{%
         Required version: 2024-11-05 v7.01l or newer,\MessageBreak%
         found version:\space\space\space\space\csname ver@hyperref.sty\endcsname.}}%
   }{\PackageNoteNoLine{pageslts}{Package hyperref not loaded.\MessageBreak%
       pageslts would support hyperref.\MessageBreak%
       The page references will NOT be hyperlinked}%
    }%
  \IfPackageLoadedT{alphalph}{%
    \newalphalph{\AlphMult}[mult]{\@Alph}{26}%
    \newalphalph{\alphMult}[mult]{\@alph}{26}%
    \newalphalph{\fnsymbolmult}[mult]{\@fnsymbol}{5}%
    }%
  \if@filesw%
  \else%
    \IfPackageLoadedTF{tikz}{%
      \PackageWarning{pageslts}%
        {It was not allowed to write to an\MessageBreak%
         .aux file. This package does not work without access\MessageBreak%
         to an .aux file.\MessageBreak%
         It is OK if the .aux file was already updated\MessageBreak%
         by a previous compiler run\MessageBreak%
         and would not have changed anyway.\MessageBreak%
        }%
    }{\PackageError{pageslts}{No writing to auxiliary file allowed}%
        {It 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%
         But it is OK if the .aux file was already updated\MessageBreak%
         by previous compiler runs\MessageBreak%
         and would not have changed anyway.\MessageBreak%
         (In that case just press Enter or Return\MessageBreak%
         to continue the compilation.)\MessageBreak%
        }%
     }%
  \fi%
  }

\def\pagesLTS@skld{0}
\IfPackageLoadedT{showkeys}{\IfPackageLoadedWithOptionsF{showkeys}{final}{%
  \def\pagesLTS@skld{1}}%
  }%

\AddToHook{enddocument/afterlastpage}{%
  \IfPackageLoadedT{showkeys}{\IfPackageLoadedWithOptionsF{showkeys}{final}{%
    \ifx\pagesLTS@skld\pagesLTS@one\relax%
    \else\PackageError{pageslts}{Package showkeys loaded after pageslts}{%
      The showkeys package with option "final" has been loaded\MessageBreak%
      after the pageslts package.\MessageBreak%
      Please first load showkeys and then pageslts}%
    \fi}%
  }%
  \ifx\pncmissing\pagesLTS@one\relax%
    \PackageError{pageslts}{pagenumbering scheme missing}{\pagesLTS@messageNPN}%
  \fi%
  \PackageInfo{pageslts}{enddocument/afterlastpage (AED): pageslts setting LastPage}%
  \ifx\pagesLTS@pnc\pagesLTS@fns%
    \def\pagesLTS@tmpA{\arabic{pagesLTS.fnsymbol.local}}%
    \ifnum\pagesLTS@esoFs=\pagesLTS@tmpA%
      \gdef\pagesLTS@rerun{0}%
    \else%
      \gdef\pagesLTS@rerun{1}%
    \fi%
    \if@filesw%
      \immediate\write\@auxout{\string\gdef\string\pagesLTS@esoFs{\pagesLTS@tmpA}}%
    \fi%
  \else%
    \ifx\pagesLTS@pnc\pagesLTS@silly%
      \def\pagesLTS@tmpA{\arabic{pagesLTS.silly.local}}%
      \ifnum\pagesLTS@esoSy=\pagesLTS@tmpA%
        \gdef\pagesLTS@rerun{0}%
      \else%
        \gdef\pagesLTS@rerun{1}%
      \fi%
      \if@filesw%
        \immediate\write\@auxout{\string\gdef\string\pagesLTS@esoSy{\pagesLTS@tmpA}}%
      \fi%
    \else%
      \ifx\pagesLTS@pnc\pagesLTS@gobble%
        \def\pagesLTS@tmpA{\arabic{pagesLTS.gobble.local}}%
        \ifnum\pagesLTS@esoGbl=\pagesLTS@tmpA%
          \gdef\pagesLTS@rerun{0}%
        \else%
          \gdef\pagesLTS@rerun{1}%
        \fi%
        \if@filesw%
          \immediate\write\@auxout{\string\gdef\string\pagesLTS@esoGbl{\pagesLTS@tmpA}}%
  \fi\fi\fi\fi%
  \pagesLTS@putlabel{LastPage}{\thepage}{1}%
  \let\pagesLTS@tmpA\undefined%
  \if@filesw%
    \ifx\pagesLTS@esovFs\pagesLTS@zero\relax%
    \else%
      \immediate\write\@auxout{\string\pagesLTS@providecounter{pagesLTS.fnsymbol.local}}%
      \immediate\write\@auxout{\string\setcounter{pagesLTS.fnsymbol.local}{\pagesLTS@esovFs}}%
    \fi%
    \ifx\pagesLTS@esovSy\pagesLTS@zero\relax%
    \else%
      \immediate\write\@auxout{\string\pagesLTS@providecounter{pagesLTS.silly.local}}%
      \immediate\write\@auxout{\string\setcounter{pagesLTS.silly.local}{\pagesLTS@esovSy}}%
    \fi%
    \ifx\pagesLTS@esovGbl\pagesLTS@zero\relax%
    \else%
      \immediate\write\@auxout{\string\pagesLTS@providecounter{pagesLTS.gobble.local}}%
      \immediate\write\@auxout{\string\setcounter{pagesLTS.gobble.local}{\pagesLTS@esovGbl}}%
    \fi%
  \fi%
  \pagesLTS@providecounter{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%
    \setcounter{pagesLTS.tmpcounter}{\value{pagesLTS.pnc.\pagesLTS@pnc}}%
    \@tempcnta=\value{pagesLTS.tmpcounter}\relax%
    \loop%
      \ifnum\@tempcnta>1\relax%
        \addtocounter{pagesLTS.tmpcounter}{-1}%
        \addtocounter{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.pnc.\pagesLTS@pnc}.local.count}{%
          -\value{pagesLTS.\pagesLTS@pnc.\arabic{pagesLTS.tmpcounter}.local.count}}%
        \@tempcnta=\value{pagesLTS.tmpcounter}\relax%
    \repeat%
  \fi%
  \if@filesw%
    \immediate\write\@auxout{\string
      \pagesLTS@providecounter{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}}%
  \fi%
  \addtocounter{page}{-1}%
  \def\pagesLTS@tmpA{\thepage}%
  \if@filesw%
    \protected@iwrite\@auxout{}{\string\gdef\string\pagesLTSlastpage{\pagesLTS@tmpA}}%
    \gdef\pagesLTS@Hy{}%
    \IfPackageLoadedT{hyperref}{\ifHy@pageanchor\pagesLTS@makeHy\fi}%
    \protected@iwrite\@auxout{}{\string\gdef\string\pagesLTSlastpageHy{\pagesLTS@Hy}}%
  \fi%
  \addtocounter{page}{+1}%
  \addtocounter{CurrentPage}{-1}%
  \edef\pagesLTS@tmpB{\arabic{CurrentPage}}%
  \if@filesw%
    \immediate\write\@auxout{\string\setcounter{pagesLTS.pagenr}{\pagesLTS@tmpB}}%
  \fi%
  \addtocounter{CurrentPage}{+1}%
  \PackageInfo{pageslts}{enddocument/afterlastpage (AED): pageslts setting VeryLastPage}%
  \pagesLTS@putlabel{VeryLastPage}{\thepage}{1}%
  \PackageInfo{pageslts}{enddocument/afterlastpage (AED): pageslts setting LastPages}%
  \pagesLTS@putlabels%
  \ifodd\pagesLTS@tmpB%
    \PackageNoteNoLine{pageslts}{Total number of pages is odd}%
  \else%
    \PackageNoteNoLine{pageslts}{Total number of pages is even}%
  \fi%
  }

\AddToHook{cmd/frontmatter/before}{%
  \xdef\pagesLTS@FMBpncn{\pagesLTS@pnc}%
  \xdef\pagesLTS@FMBpncp{\arabic{pagesLTS.current.local.\pagesLTS@pnc}}%
  }

\AddToHook{cmd/frontmatter/after}{%
  \xdef\pagesLTS@FMEpncn{\pagesLTS@pnc}%
  \ifx\pagesLTS@FMBpncn\pagesLTS@FMEpncn%
  \else%
    \ifx\pagesLTS@FMBpncn\pagesLTS@zero%
    \else%
      \ifx\pagesLTS@FMBpncp\pagesLTS@one%
        \PackageWarning{pageslts}{\string\pagenumbering\space before \string\frontmatter:\MessageBreak%
          Do not use \string\pagenumbering{\pagesLTS@FMBpncn} before \string\frontmatter\MessageBreak%
          on the same page!\MessageBreak%
          \string\frontmatter\space (re)defines the page numbering scheme to \pagesLTS@FMEpncn ,\MessageBreak%
          thus earlier use of \string\pagenumbering{\pagesLTS@FMBpncn} %
          on the same page is useless anyway\MessageBreak}%
      \fi%
    \fi%
  \fi%
  }

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

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