% \iffalse meta-comment
%
% File: thumbs.dtx
% Version: 2026-01-18 v1.1d
% Info: Thumb marks and overview page(s)
%
% Copyright © 2010 - 2026 by
%    H.-Martin Münch <Martin dot Muench at Uni-Bonn dot de>
%
% 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 Münch.
%
% This work consists of the main source file thumbs.dtx,
% the README, and the derived files
%    thumbs.sty, thumbs.pdf,
%    thumbs.ins, thumbs.drv,
%    thumbs-example.tex, thumbs-example.pdf.
%
% "thumbs" is available on CTAN:
% https://ctan.org/pkg/thumbs
%
% Also a TDS.ZIP file is provided that contains all the files
% already sorted in a TDS tree:
% https://mirror.ctan.org/install/macros/latex/contrib/thumbs.tds.zip
%
%<*ignore>
\begingroup
  \catcode123=1 %
  \catcode125=2 %
  \def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
         \ifx\csname processbatchFile\endcsname\relax\else1\fi
         \ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{**************************************************************************}
\Msg{* Installation                                                           *}
\Msg{* Package: thumbs 2026-01-18 v1.1d Thumb marks and overview page(s) (HMM)*}
\Msg{**************************************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax
\preamble

This is a generated file.

Project: thumbs
Version: 2026-01-18 v1.1d
Info: Thumb marks and overview page(s)

Copyright (C) 2010 - 2026 by
    H.-Martin Muench <Martin dot Muench at Uni-Bonn dot de>

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 work consists of the main source file thumbs.dtx,
the README, and the derived files
   thumbs.sty, thumbs.pdf,
   thumbs.ins, thumbs.drv,
   thumbs-example.tex, thumbs-example.pdf.

In memoriam
 Claudia Simone Barth + 1996-01-30
 Tommy Muench         + 2014-01-02
 Hans-Klaus Muench    + 2014-08-24

\endpreamble
\let\MetaPrefix\DoubleperCent

\generate{%
  \file{thumbs.ins}{\from{thumbs.dtx}{install}}%
  \file{thumbs.drv}{\from{thumbs.dtx}{driver}}%
  \usedir{tex/latex/thumbs}%
  \file{thumbs.sty}{\from{thumbs.dtx}{package}}%
  \usedir{doc/latex/thumbs}%
  \file{thumbs-example.tex}{\from{thumbs.dtx}{example}}%
}

\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* file into a directory searched by TeX:}
\Msg{*}
\Msg{*  thumbs.sty}
\Msg{*}
\Msg{* To produce the documentation run the file `thumbs.drv'}
\Msg{* through (pdf)LaTeX, e.g.}
\Msg{*  pdflatex thumbs.drv}
\Msg{*  makeindex -s gind.ist thumbs.idx}
\Msg{*  pdflatex thumbs.drv}
\Msg{*  makeindex -s gind.ist thumbs.idx}
\Msg{*  pdflatex thumbs.drv}
\Msg{*}
\Msg{* At least three runs are necessary e.g. to get the}
\Msg{*  references right!}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}

\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%
% \section{The documentation driver file}
%
% The next bit of code contains the documentation driver file for
% \TeX , i.\,e., the file that will produce the documentation you
% are currently reading. It will be extracted from this file by the
% \texttt{docstrip} programme. That is, run \LaTeX{} on \texttt{docstrip}
% and specify the \texttt{driver} option when \texttt{docstrip}
% asks for options.
%
%    \begin{macrocode}
%<*driver>
\NeedsTeXFormat{LaTeX2e}[2025-06-01]
\ProvidesFile{thumbs.drv}[2026-01-18 v1.1d Thumb marks and overview page(s) (HMM)]
\documentclass[landscape]{ltxdoc}[2024/02/08]%     v2.1j Standard LaTeX documentation class
\usepackage{geometry}[2020/01/02]%                 v5.9  Page Geometry
\usepackage{holtxdoc}[2019/12/09]%                 v0.30 Private additional ltxdoc support (HO)
\hypersetup{%
 pdfsubject={Thumb marks and overview page(s) (HMM)},%
 pdfkeywords={LaTeX, thumb, thumbs, thumb index, thumbs index, index},%
 pdfencoding=auto,%
 pdflang={en},%
 breaklinks=true,%
 linktoc=all,%
 pdfstartview=FitH,%
 pdfpagelayout=OneColumn,%
 bookmarksnumbered=true,%
 bookmarksopen=true,%
 bookmarksopenlevel=3,%
 pdfmenubar=true,%
 pdftoolbar=true,%
 pdfwindowui=true,%
 pdfnewwindow=true%
}
\CodelineIndex
\hyphenation{printing docu-ment docu-menta-tion}
\DeclareMathAlphabet{\mathup}{OT1}{\familydefault}{m}{n}
\DeclareRobustCommand{\unit}[1]{\ensuremath{\mathord{\thinspace\mathup{#1}}}}
\providecommand{\eTeX}{\ensuremath{\m@th\varepsilon}-\TeX}
\begin{document}
  \DocInput{thumbs.dtx}%
\end{document}
%</driver>
%    \end{macrocode}
% \fi
%
% \GetFileInfo{thumbs.drv}
%
% \begingroup
%   \def\x{\#,\$,\^,\_,\~,\ ,\&,\{,\},\%}%
%   \makeatletter
%   \@onelevel@sanitize\x
% \expandafter\endgroup
% \expandafter\DoNotIndex\expandafter{\x}
% \expandafter\DoNotIndex\expandafter{\string\ }
% \begingroup
%   \makeatletter
%     \lccode`9=32\relax
%     \lowercase{%^^A
%       \edef\x{\noexpand\DoNotIndex{\@backslashchar9}}%^^A
%     }%^^A
%   \expandafter\endgroup\x
%
% \DoNotIndex{\ ,\,,\@auxout,\@expl@@@shipout@add@foreground@picture@@n,\@gobble,\@gobbletwo,%
%  \@ifl@t@r,\@ifundefined,\@instreamthumb,\@tempcnta,\@tempdima,\@tempdimb,\@tempdimc,\@thumbsout,%
%  \@unused,\@whilenum,\addcontentsline,\addtocontents,\addtocounter,\addtolength,\advance,\AlphAlph,%
%  \arabic,\begin,\bigskip,\box,\c@page,\c@Th@mbTmpA,\c@Th@mbTmpB,\chapter,\cleardoublepage,\clearpage,%
%  \closein,\closeout,\color,\colorlet,\csname,\DeclareKeys,\DeclareMathAlphabet,\DeclareRobustCommand,%
%  \dimexpr,\divide,\do,\documentclass,\dotfill,\empty,\end,\endcsname,\ensuremath,\euro,\evenmarkindent,%
%  \evenprintvoffset,\evensidemargin,\eventxtindent,\expanded,\familydefault,\fill,\fmtversion,\footskip,\frac,%
%  \gdef,\glossary,\hbox,\headheight,\headsep,\hfill,\hrulefill,\hsize,\hspace,\Huge,\hyperref,%
%  \if@filesw,\if@twocolumn,\if@twoside,\ifdim,\ifnum,\ifodd,\IfPackageLoadedF,\IfPackageLoadedT,%
%  \IfPackageLoadedTF,\ifx,\immediate,\index,\jobname,\label,\LaTeX,\ldots,\leaders,\leftskip,\linebreak,%
%  \lipsum,\listfiles,\makeatletter,\makeatother,\MakeUppercase,\MakeUppercases,\markboth,\mathord,\mathup,%
%  \message,\MessageBreak,\NeedsTeXFormat,\newcommand,\newcounter,\newdimen,\newline,\newpage,\noindent,%
%  \nopagecolor,\normalsize,\null,\number,\numexpr,\oddsidemargin,\PackageError,\PackageInfo,\PackageWarning,%
%  \PackageWarningNoLine,\pagebreak,\pagecolor,\pagenumbering,\pageref,\paperheight,\paperwidth,\parbox,%
%  \parindent,\PassOptionsToPackage,\phantom,\phantomsection,\ProcessKeyOptions,\protect,%
%  \protected@file@percent,\ProvidesPackage,\put,\raggedleft,\raggedright,\read,\renewcommand,\RequirePackage,%
%  \RerunFileCheck,\rlap,\rule,\section,\setcounter,\SetKeys,\setlength,\settowidth,\smallskip,\space,\ss,%
%  \stepcounter,\tableofcontents,\textbf,\textheight,\textit,\textquotedblleft,\textquotedblright,\textsc,%
%  \textsf,\textsuperscript,\texttt,\textwidth,\the,\thepage,\thepagecolor,\thinspace,\topmargin,%
%  \url,\usepackage,\value,\vbox,\verb,\voffset,\vspace,\write,\z@}
%
% \title{The \xpackage{thumbs} package}
% \author{H.-Martin Münch\\\xemail{Martin.Muench at Uni-Bonn.de}}
% \date{2026-01-18 v1.1d}
% \maketitle
%
% \begin{abstract}
%  \noindent This \LaTeX{} package allows to create one or more
%  customizable thumb index(es), providing a quick and easy reference method
%  for large documents. It must be loaded after the page size has been set,
%  when printing the document no~\textquotedblleft shrink to
%  page\textquotedblright{} should be used, and a printer capable of
%  printing up to the border of the sheet of paper is needed
%  (or afterwards cutting the paper, cf.~the \xpackage{crop} package).
% \end{abstract}
%
% \bigskip
%
% \noindent Disclaimer for web links: The author is not responsible for any contents
% referred to in this work unless having full knowledge of illegal contents.
% If any damage occurs by the use of information presented there,
% only the author of the respective pages might be liable,
% not the one who has referred to those pages.
% \newpage
% \tableofcontents
% \newpage
%
% \section{Introduction\label{s:Introduction}}
% \indent This \LaTeX{} package puts running, customizable thumb marks
% into the outer margin, moving downward as the chapter number
% (or whatever shall be marked by the thumb marks) increases.
% Additionally an overview page/table of thumb marks can be added automatically,
% which gives the respective names of the thumbed objects,
% the page where the object/thumb mark first appears,
% and the thumb mark itself at the respective position. The thumb marks are probably useful
% for documents, where a quick and easy way to find \hbox{e.\,g.}~a~chapter is needed, for example
% in reference guides, anthologies, or quite large documents.\newline
% \xpackage{thumbs} must be loaded after the page size has been set,
% when printing the document no~\textquotedblleft shrink to page\textquotedblright{} should
% be used, a~printer capable of printing up to the border of the sheet of paper is needed
% (or~afterwards cutting the paper, cf. the \xpackage{crop} packeg).\newline
% Usage with |\usepackage[landscape]{geometry}|, |\documentclass[landscape]{|\ldots|}|,
% |\usepackage[landscape]{geometry}|, \linebreak |\usepackage{lscape}|, or |\usepackage{pdflscape}|
% is possible.\par
%
% \noindent A note on terms and definitions:\par\vspace{+0.5\baselineskip}
%
% \noindent\textbf{Thumb index}:\vspace{-0.5\baselineskip}
% \begin{quote}
%   A thumb index, also called a cut{-}in index or an index notch, is a round cut{-}out in the pages
%   of dictionaries, encyclopedias, Bibles and other large religious books, and various sectioned,
%   often alphabetic, reference works, used to locate entries starting at a particular letter or section.
%   The individual notches are called thumb cuts and enable the reader to turn to any section they want.
% \end{quote}\vspace{-0.5\baselineskip}
% (\url{https://en.wikipedia.org/w/index.php?title=Thumb_index&oldid=1297058528};\newline
% see also \url{https://de.wikipedia.org/wiki/Daumenregister})\newline
% The \xpackage{thumbs} package does not auto{-}magically produce cuts
% in the paper, while the produced marks could be used to determine
% where to cut (and leaving one mark at the bottom of each cut).
% Therefore, strictly speaking, \xpackage{thumbs} is the wrong term.\par\vspace{+0.5\baselineskip}
%
% \noindent\textbf{Edge index}:\vspace{-0.5\baselineskip}
% \begin{quote}
%   An edge index is a form of index that consists of marks on the edges of the pages of a printed
%   work. These marks are step-like printed and usually contain order words, letters, or numbers,
%   \hbox{(e.\,g.,} A~to Z in a dictionary or telephone book). Usually, they are colored and help to find
%   desired points, especially in reference works. They are created by printing to the edge of the
%   sheet so that they are visible on the closed books' edge. Advantageously, edge indexing is part
%   of the printing process, permits nearly unlimited headings, and does not add to the cost of
%   binding. These are offset by the disadvantage of being unable to know what a mark refers~to
%   without opening the book. \ldots\newline
%   When each edge index mark labels one chapter, the desired one can be found by counting the marks.
%   When the edge index marks label first letters in a dictionary or telephone book, some can be
%   identified by their \textquotedblleft thickness\textquotedblright , i.\,e.~in English there are
%   only few words beginning with \textquotedblleft Q\textquotedblright{} but a lot beginning with
%   \textquotedblleft S\textquotedblright . \ldots\newline
%   An edge index is distinct from a thumb index, but the terms thumb index or chapter thumbs
%   have been applied to edge indices.
% \end{quote}\vspace{-0.5\baselineskip}
% (\url{https://en.wikipedia.org/w/index.php?title=Edge_index&oldid=1303541874};\newline
% see also \url{https://de.wikipedia.org/wiki/Handmarke} and\newline
% \url{http://de.wikipedia.org/wiki/Datei:Farbschnitt_und_Register.jpg}
% Book with blue cut decoration and edge index\newline
% \url{http://de.wikipedia.org/wiki/Datei:HandmarkeKopfschnitt.jpg}
% Edge index at the top cut\newline
% \url{http://de.wikipedia.org/wiki/Datei:SeitennummerierungEck.JPG}
% Page number at the top cut edge)\par
%
% \noindent The correct terms therefore are edge index and edge index marks.\newline
% When looking at the section about alternatives to this package
% (p.~\pageref{sec:Alternatives}), \textquotedblleft thumb (mark)\textquotedblright{} %
% obviousely is the term which is colloquially used for it.
% (A~search for \textquotedblleft edge\textquotedblright{} at
% \href{https://www.ctan.org/}{ctan.org} on 31. July 2023 returned no relevant result.)
% Thus the colloquial term has been kept for this package
% while here providing the information about the formal one.
%
% \section{Usage}
% \subsection{Loading}
% \indent Load the package placing
% \begin{quote}
%   |\usepackage[<|\textit{options}|>]{thumbs}|
% \end{quote}
% \noindent into the preamble of your \LaTeXe\ source file.\newline
% The \xpackage{thumbs} package takes the dimensions of the page
% |\AddToHook{begindocument}[start]| and does not react to changes afterwards.
% Therefore this package must be loaded \emph{after} the page dimensions
% have been set, e.\,g.~with package \xpackage{geometry}
% (\url{https://www.ctan.org/pkg/geometry}).
% Of course it is also OK to just keep the default page/{}paper settings,
% but when anything is changed, it must be done before \xpackage{thumbs}
% executes its |\AddToHook{begindocument}[start]| code.\newline
% The format of the paper, where the document shall be printed upon,
% should also be used for creating the document. Then the document can
% be printed without adapting the size, like e.\,g.~\textquotedblleft shrink
% to page\textquotedblright . That would add a white border around the document
% and by moving the thumb marks from the edge of the paper they no longer appear
% at the side of the stack of paper. It is also necessary to use a printer
% capable of printing up to the border of the sheet of paper. Alternatively
% it is possible after the printing to cut the paper to the right size.
% (The \xpackage{crop}\index{crop} package is very useful for this.)
% While performing the cutting manually is probably quite cumbersome,
% printing houses use paper, which is larger than the  desired format,
% and afterwards cut it to format.\newline
% Some faulty outdated version of a \xfile{pdf}-viewer added a white line
% at the bottom and right side of the document when presenting it.
% This did not change the printed version. To test for this problem,
% a doublepage of the example file has been completely coloured.
% (Probably better exclude those two pages from printing\ldots)\newline
% When using the thumb marks overview page (edge index), it is necessary
% to |\protect| entries like |\pi| (same as with entries in tables of contents,
% figures, tables,\ldots).
%
% \subsection{Options}
% \DescribeMacro{options}
% \indent The \xpackage{thumbs} package takes the following options:
%
% \subsubsection{linefill\label{sss:linefill}}
% \DescribeMacro{linefill}
% \indent Option |linefill| wants to know how the line between object
% (e.\,g.~chapter name) and page number shall be filled at the overview
% page. Empty option will result in a blank line, |line| will fill the distance
% with a line, |dots| will fill the distance with dots.
%
% \subsubsection{thumblink\label{sss:thumblink}}
% \DescribeMacro{thumblink}
% \indent Option |thumblink| determines, what is hyperlinked at the thumb marks
% overview page (when the \xpackage{hyperref} package is used):
%
% \begin{description}
% \item[- |none|] creates \emph{none} hyperlinks
%
% \item[- |title|] hyperlinks the \emph{titles} of the thumb marks
%
% \item[- |page|] hyperlinks the \emph{page} numbers of the thumb marks
%
% \item[- |titleandpage|] hyperlinks the \emph{title and page} numbers of the thumb marks
%
% \item[- |line|] hyperlinks the whole \emph{line}, i.\,e. title, dots%
%        (or line or whatsoever) and page numbers of the thumb marks
%
% \item[- |rule|] hyperlinks the whole \emph{rule}.
% \end{description}
%
% \subsubsection{minheight\label{sss:minheight}}
% \DescribeMacro{minheight}
% \indent Option |minheight| wants to know the minimal vertical extension
% of each thumb mark. This is only useful in combination with option |height=auto|
% (see below). When the height is automatically calculated and smaller than
% the |minheight| value, the height is set equal to the given |minheight| value
% and a new column/page of thumb marks is used. The default value is
% $47\unit{pt}$\ $(\approx 16.5\unit{mm} \approx 0.65\unit{in})$.
%
% \subsubsection{height\label{sss:height}}
% \DescribeMacro{height}
% \indent Option |height| wants to know the vertical extension of each thumb mark.
% The default value \textquotedblleft |auto|\textquotedblright\ calculates
% an appropriate value automatically decreasing with increasing number of thumb
% marks (but fixed for each document). When the height is smaller than |minheight|,
% this package deems this as too small and instead uses a new column/page of thumb
% marks. If smaller thumb marks are really wanted, choose a smaller |minheight|
% (e.\,g.~$0\unit{pt}$).
%
% \subsubsection{width\label{sss:width}}
% \DescribeMacro{width}
% \indent Option |width| wants to know the horizontal extension of each thumb mark.
% The default option-value \textquotedblleft |auto|\textquotedblright\ calculates
% a width-value automatically: (|\paperwidth| minus |\textwidth|), which is the
% total width of inner and outer margin, divided by~$4$. Instead of this, any
% positive width given by the user is accepted. (Try |width={\paperwidth}|
% in the example!) Option |width={autoauto}| leads to thumb marks, which are
% just wide enough to fit the widest thumb mark text.
%
% \subsubsection{distance\label{sss:distance}}
% \DescribeMacro{distance}
% \indent Option |distance| wants to know the vertical spacing between
% two thumb marks. The default value is $2\unit{mm}$.
%
% \subsubsection{topthumbmargin\label{sss:topthumbmargin}}
% \DescribeMacro{topthumbmargin}
% \indent Option |topthumbmargin| wants to know the vertical spacing between
% the upper page (paper) border and top thumb mark. The default (|auto|)
% is $1\unit{inch}$ plus |\th@bmsvoffset| plus |\topmargin|.
% Dimensions (e.\,g.~$1\unit{cm}$) are also accepted.
%
% \subsubsection{bottomthumbmargin\label{sss:bottomthumbmargin}}
% \DescribeMacro{bottomthumbmargin}
% \indent Option |bottomthumbmargin| wants to know the vertical spacing between
% the lower page (paper) border and last thumb mark. The default (|auto|) for the
% position of the last thumb is\newline
% |1in+\topmargin-\th@mbsdistance+\th@mbheighty+\headheight+\headsep+\textheight|
% |+\footskip-\th@mbsdistance|\newline
% |-\th@mbheighty|.\newline
% Dimensions (e.\,g.~$1\unit{cm}$) are also accepted.
%
% \subsubsection{eventxtindent\label{sss:eventxtindent}}
% \DescribeMacro{eventxtindent}
% \indent Option |eventxtindent| expects a dimension (default value: $5\unit{pt}$,
% negative values are possible, of course),
% by which the text inside of thumb marks on even pages is moved away from the
% page edge, i.e. to the right. Probably using the same or at least a similar value
% as for option |oddtxtexdent| makes sense.
%
% \subsubsection{oddtxtexdent\label{sss:oddtxtexdent}}
% \DescribeMacro{oddtxtexdent}
% \indent Option |oddtxtexdent| expects a dimension (default value: $5\unit{pt}$,
% negative values are possible, of course),
% by which the text inside of thumb marks on odd pages is moved away from the
% page edge, i.e. to the left. Probably using the same or at least a similar value
% as for option |eventxtindent| makes sense.
%
% \subsubsection{evenmarkindent\label{sss:evenmarkindent}}
% \DescribeMacro{evenmarkindent}
% \indent Option |evenmarkindent| expects a dimension (default value: $0\unit{pt}$,
% negative values are possible, of course),
% by which the thumb marks (background and text) on even pages are moved away from the
% page edge, i.e. to the right. This might be useful when the paper,
% onto which the document is printed, is later cut to another format.
% Probably using the same or at least a similar value as for option |oddmarkexdent|
% makes sense.
%
% \subsubsection{oddmarkexdent\label{sss:oddmarkexdent}}
% \DescribeMacro{oddmarkexdent}
% \indent Option |oddmarkexdent| expects a dimension (default value: $0\unit{pt}$,
% negative values are possible, of course),
% by which the thumb marks (background and text) on odd pages are moved away from the
% page edge, i.e. to the left. This might be useful when the paper,
% onto which the document is printed, is later cut to another format.
% Probably using the same or at least a similar value as for option |oddmarkexdent|
% makes sense.
%
% \subsubsection{evenprintvoffset\label{sss:evenprintvoffset}}
% \DescribeMacro{evenprintvoffset}
% \indent Option |evenprintvoffset| expects a dimension (default value: $0\unit{pt}$,
% negative values are possible, of course),
% by which the thumb marks (background and text) on even pages are moved downwards.
% This might be useful when a duplex printer shifts recto and verso pages
% against each other by some small amount, \hbox{e.\,g.} a~millimeter or two,
% which is not uncommon. Please do not use this option with another value than $0\unit{pt}$
% for files which you submit to other persons. Their printer probably shifts the
% pages by another amount, which might even lead to increased mismatch
% if both printers shift in opposite directions. Ideally the pdf viewer
% would correct the shift depending on printer (or at least give some option
% similar to \textquotedblleft shift verso pages by
% \hbox{$x\unit{mm}$\textquotedblright{}.}
%
% \subsubsection{leftindexruleplus\label{sss:leftindexruleplus}}
% \DescribeMacro{leftindexruleplus}
% \indent Option |leftindexruleplus| expects a dimension (default value: $0\unit{pt}$,
% negative values are possible, of course),
% by which the rules of the thumb mark entries in the thumb mark overview (edge index)
% on left pages are made longer (or shorter, if negative value is given). Sometimes
% those rules end a bit too early. While I did not determine yet why they are behaving
% like this, option |leftindexruleplus| allows to add e.\,g.{} |\evensidemargin|
% (or $20\unit{pt}$ or another length) to the rules.
%
% \pagebreak
% \subsubsection{frame\label{sss:frame}}
% \DescribeMacro{frame}
% \indent Option |frame| is |\empty| by default. \textsc{Bjorn Victor} suggested
% to use thumb marks consisting only of frames instead of filled rectangles.
% This can be accomplished by giving a length to the option |frame|,
% for example |frame={2pt}|. The thumb mark is still filled, but with
% |\thepagecolor|, which makes it appear as empty.
%
% \subsubsection{frameinnercolor\label{sss:frameinnercolor}}
% \DescribeMacro{frameinnercolor}
% \indent If option |frame| is used with some length value (i.\,e. line thickness),
% the frame is filled with |\thepagecolor| by default. When another filling
% is whished for, the option |frameinnercolor| accepts colours,
% for example |frameinnercolor={yellow}|.
%
% \subsubsection{txtcentered\label{sss:txtcentered}}
% \DescribeMacro{txtcentered}
% \indent The thumb's text is placed using either |\raggedright| or |\raggedleft|
% (depending on left or right page for double sided documents).
% With option |txtcentered=true| the thumb's text is centered instead.
%
% \subsubsection{ignorehoffset, ignorevoffset\label{sss:ignoreoffset}}
% \DescribeMacro{ignorehoffset}
% \DescribeMacro{ignorevoffset}
% \indent Usually |\hoffset| and |\voffset| should be regarded,
% but moving the thumb marks away from the paper edge probably
% makes them useless. Therefore |\hoffset| and |\voffset| are ignored
% by default, or when option |ignorehoffset| or |ignorehoffset=true| is used
% (and |ignorevoffset| or |ignorevoffset=true|, respectively).
% But in case that the user wants to print at one sort of paper
% but later trim it to another one, regarding the offsets would be
% necessary (for example when using the \xpackage{crop}\index{crop} package).
% Therefore |ignorehoffset=false| and |ignorevoffset=false| can be used
% to regard these offsets. (Combinations |ignorehoffset=true, ignorevoffset=false|
% and |ignorehoffset=false, ignorevoffset=true| are also possible.)
%
% \subsubsection{nophantomsection\label{sss:nophantomsection}}
% \DescribeMacro{nophantomsection}
% \indent Option |nophantomsection| globally disables the automatic placement of a
% |\phantomsection| before the thumb marks. Generally it is desirable to have a
% hyperlink from the thumbs overview page to lead to the thumb mark and not to some
% earlier place. Therefore automatically a |\phantomsection| is placed before each
% thumb mark. But for example when using the thumb mark after a |\chapter{...}|
% command, it is probably nicer to have the link point at the top of that chapter's
% title (instead of the line below it). When automatic placing of the
% |\phantomsection|s has been globally disabled, nevertheless manual use of
% |\phantomsection| is still possible. The other way round: When automatic placing
% of the |\phantomsection|s has \emph{not} been globally disabled, it can be disabled
% just for the following thumb mark by the command |\thumbsnophantom|.
%
% \subsubsection{plainthumbsoverview\label{sss:plainthumbsoverview}}
% \DescribeMacro{plainthumbsoverview}
% \indent Option |plainthumbsoverview| (|false| by default, but |true| if used)
% removes the coloured rules behind the entries on the overview pages and prints
% the text in the current colour (usually black).
% (Feature requested by \textsc{bplasa}.)
%
% \pagebreak
% \subsubsection{verbose, silent\label{sss:verbose}}
% \DescribeMacro{verbose, silent}
% \indent Option |verbose=false| (the default) suppresses some messages,
% which otherwise are presented at the screen and written into the \xfile{log}~file.
% Look for\newline
% |************** THUMB dimensions **************|\newline
% in the \xfile{log} file for height and width of the thumb marks as well as
% top and bottom thumb marks margins.~--
% Instead of |verbose=false| also |silent=true| and instead of |verbose=true|
% also |silent=false| can be used.
%
% \subsubsection{draft, final\label{sss:draft}}
% \DescribeMacro{draft, final}
% \indent Option |draft| (\emph{not} the default) sets the thumb mark width to
% $2\unit{pt}$, thumb mark text colour to black and thumb mark background colour
% to grey (|gray|). Either do not use this option with the \xpackage{thumbs} package at all,
% or use |draft=false|, or |final|, or |final=true| to get the original appearance
% of the thumb marks.
%
% \subsubsection{hidethumbs\label{sss:hidethumbs}}
% \DescribeMacro{hidethumbs}
% \indent Option |hidethumbs| (\emph{not} the default) prevents \xpackage{thumbs}
% to create thumb marks (or thumb marks overview pages). This could be useful
% when thumb marks were placed, but for some reason no thumb marks (and overview pages)
% shall be placed. Removing |\usepackage[...]{thumbs}| would not work but
% create errors for unknown commands (e.\,g.~|\addthumb|, |\addtitlethumb|,
% |\thumbnewcolumn|, |\stopthumb|, |\continuethumb|, |\addthumbsoverviewtocontents|,
% |\thumbsoverview|, |\thumbsoverviewback|, \linebreak |\thumbsoverviewverso|, and
% |\thumbsoverviewdouble|). (A~|\jobname.tmb| file is created nevertheless.)~--
% Either do not use this option with the \xpackage{thumbs}
% package at all, or use |hidethumbs=false| to get the original appearance
% of the thumb marks.
%
% \subsubsection{righttoleft\label{sss:righttoleft}}
% \DescribeMacro{righttoleft}
% \indent Option |righttoleft| (\emph{not} the default) tells the \xpackage{thumbs} package
% that right-to-left writing is used (e.\,g.~Arabic) and the thumb marks need to be placed
% on the other edge of the paper. When using this option, also options like
% |eventxtindent| and |oddtxtexdent| need to be adapted, and you must expect to need to
% use |even| when you want to change |odd| and to use negative dimensions
% when you want to use positive ones -- everything is mirrored, but naming and such
% is not changed automatically.
%
% \subsubsection{Obsolete options: \texttt{pagecolor}, \texttt{evenindent}, \texttt{oddexdent}}
% \indent The following obsolete options have been removed:
% \begin{description}
% \item[-] |pagecolor|: Instead the \xpackage{pagecolor} package is used. Use |\pagecolor{...}|
%            \emph{after} |\usepackage[...]{thumbs}| and \emph{before} \linebreak
%            |\begin{document}| to define a background colour of the pages.
% \item[-] |evenindent|: It was replaced by option |eventxtindent|.
% \item[-] |oddexdent|: It was replaced by option |oddtxtexdent|.
%\end{description}
%
% \newpage
% \subsection{Commands to be used in the document}
% \subsubsection{\textbackslash addthumb}
% \DescribeMacro{\addthumb}
% To add a thumb mark, use the |\addthumb| command, which has these four parameters:
% \begin{enumerate}
% \item a title for the thumb mark (for the thumb marks overview page,
%         e.\,g.~the chapter title),
%
% \item the text to be displayed in the thumb mark (for example the chapter
%         number: |\thechapter|),
%
% \item the colour of the text in the thumb mark,
%
% \item and the background colour of the thumb mark
% \end{enumerate}
% (parameters in this order) at the page where you want this thumb mark placed
% (for the first time).
%
% \subsubsection{\textbackslash addtitlethumb}
% \DescribeMacro{\addtitlethumb}
% When a thumb mark shall not or cannot be placed on a page, e.\,g.~at the title page or
% when using |\includepdf| from \xpackage{pdfpages} package, but the reference in the thumb
% marks overview nevertheless shall name that page number and hyperlink to that page,
% |\addtitlethumb| can be used at the following page. It has five arguments. The arguments
% one to four are identical to the ones of |\addthumb| (see above),
% and the fifth argument consists of the label of the page, where the hyperlink
% at the thumb marks overview page shall link to. The \xpackage{thumbs} package does
% \emph{not} create that label!
% If manually no label can be placed on the first page, the label \texttt{pagesLTS.0}
% from the \xpackage{pageslts} package (needs to be loaded explicitly!) can be used.
%
% \subsubsection{\textbackslash stopthumb and \textbackslash continuethumb}
% \DescribeMacro{\stopthumb}
% \DescribeMacro{\continuethumb}
% When a page (or pages) shall have no thumb marks, use the |\stopthumb| command
% (without parameters). Placing another thumb mark with |\addthumb| or |\addtitlethumb|
% or using the command |\continuethumb| continues the thumb marks.
%
% \subsubsection{\textbackslash thumbsoverview/back/verso/double}
% \DescribeMacro{\thumbsoverview}
% \DescribeMacro{\thumbsoverviewback}
% \DescribeMacro{\thumbsoverviewverso}
% \DescribeMacro{\thumbsoverviewdouble}
% The commands |\thumbsoverview|, |\thumbsoverviewback|, |\thumbsoverviewverso|, and/or
% |\thumbsoverviewdouble| is/are used to place the overview page(s) for the thumb marks
% (edge index). Their single parameter is used to mark this page/these pages%
% (e.\,g.~in the page header). If these marks are not wished, |\thumbsoverview...{}|
% will generate empty marks in the page header(s). |\thumbsoverview| can be used
% more than once (for example at the beginning and at the end of the document,
% or |\thumbsoverview| at the beginning and |\thumbsoverviewback| at the end).
% The overviews have labels |TableOfThumbs1|, |TableOfThumbs2|, and so on,
% which can be referred to with e.\,g.{} |\pageref{TableOfThumbs1}|.
% The reference |TableOfThumbs| (without number) aims at the last used Table of Thumbs
% (for compatibility with older versions of this package). When using option |righttoleft|,
% the marks are placed at the other edge of the page than listed here.
% \begin{description}
% \item[-] |\thumbsoverview| prints the thumb marks at the right side
%            and (in |twoside| mode) skips left sides (useful e.\,g.{} at the beginning
%            of a document).
%
% \item[-] |\thumbsoverviewback| prints the thumb marks at the left side
%            and (in |twoside| mode) skips right sides (useful e.\,g.{} at the end
%            of a document).
%
% \item[-] |\thumbsoverviewverso| prints the thumb marks at the right side
%            and (in |twoside| mode) repeats them at the next left side and so on
%           (useful anywhere in the document and when one wants to prevent empty
%            pages).
%
% \item[-] |\thumbsoverviewdouble| prints the thumb marks at the left side
%            and (in |twoside| mode) repeats them at the next right side and so on
%            (useful anywhere in the document and when one wants to prevent empty
%             pages).
% \end{description}
% \smallskip
%
% \subsubsection{\textbackslash thumbnewcolumn}
% \DescribeMacro{\thumbnewcolumn}
% With the command |\thumbnewcolumn| a new column can be started, even if the current one
% was not filled. This could be useful e.\,g.{} for a dictionary, which uses one column for
% translations from language A to language B, and the second column for translations
% from language B to language A. But in that case one probably should increase the
% size of the thumb marks, so that $26$~thumb marks (in~case of the Latin alphabet)
% fill one thumb column. Do not use |\thumbnewcolumn| on a page where |\addthumb| was
% already used, but use |\addthumb| immediately after |\thumbnewcolumn|.
%
% \subsubsection{\textbackslash addthumbsoverviewtocontents}
% \DescribeMacro{\addthumbsoverviewtocontents}
% |\addthumbsoverviewtocontents| with two arguments is a replacement for
% |\addcontentsline{toc}{<level>}{<text>}|, where the first argument of
% |\addthumbsoverviewtocontents| is for |<level>| and the second for |<text>|.
% If an entry of the thumbs mark overview shall be placed in the table of contents,
% |\addthumbsoverviewtocontents| with its arguments should be used immediately before
% |\thumbsoverview|.
%
% \subsubsection{\textbackslash thumbsnophantom}
% \DescribeMacro{\thumbsnophantom}
% When automatic placing of the |\phantomsection|s has \emph{not} been globally
% disabled by using option |nophantomsection| (see subsection~\ref{sss:nophantomsection}),
% it can be disabled just for the following thumb mark by the command |\thumbsnophantom|.
%
% \subsection{Changing thumb colour and text\label{ss:VariableThumb}}%
% \index{Changing thumb colour and text}%
% \DescribeMacro{Changing thumb colour and~text}%
% It is  possible to change the colour and text of an existing thumb mark.
% To accomplish this, in the preamble two new colours must be defined, for example:
%
%\begin{verbatim}
%\xdef\thetextchangingcolour{red}%
%\colorlet{textchangingcolour}{\thetextchangingcolour}%
%
%\xdef\themarkchangingcolour{green}%
%\colorlet{markchangingcolour}{\themarkchangingcolour}%
%\end{verbatim}
%
% \noindent and two commands for the text, for example:
%
%\begin{verbatim}
%\DeclareRobustCommand{\thethumbchangingtextE}{\Huge{\textbf{E}}}
%\DeclareRobustCommand{\thethumbchangingtexte}{\Huge{\textbf{e}}}
%
%\gdef\thumbchangingtext{\thethumbchangingtexte}
%\end{verbatim}
%
% \noindent Now a thumb mark added with
% \hbox{|\addthumb{Name}{\protect\thumbchangingtext}{textchangingcolour}{markchangingcolour}|}
% appears as red text \textquotedblleft E\textquotedblright{} on green background,
% but really it is not \texttt{red} but \texttt{textchangingcolour}
% (which was defined as \texttt{red}) and not \texttt{green} but
% \texttt{markchangingcolour} (which was defined as \texttt{green})
% and not \textquotedblleft E\textquotedblright{} but
% |\thumbchangingtext|, which currently just happens (well, on purpose)
% to be \textquotedblleft E\textquotedblright .
%
% \noindent Some pages(s) later:
%
% \begin{verbatim}
%\xdef\thetextchangingcolour{blue}%
%\colorlet{textchangingcolour}{\thetextchangingcolour}%
%
%\xdef\themarkchangingcolour{yellow}%
%\colorlet{markchangingcolour}{\themarkchangingcolour}%
%
%\gdef\thumbchangingtext{\thethumbchangingtexte}%
%\end{verbatim}
%
% \noindent Here the thumb mark still uses \texttt{textchangingcolour},
% \texttt{markchangingcolour}, and |\thumbchangingtext|,
% but instead of \texttt{red}, \texttt{green}, and \textquotedblleft E\textquotedblright{}
% those have been redefined to \texttt{blue}, \texttt{yellow}, and
% \textquotedblleft e\textquotedblright{}. Instead of |\thumbchangingtext|
% also some variable like |\thepage| can be used.\newline
% For the thumb marks overview page(s) it must be decided which colours and text
% to use and the according definitions have to be made before that page/those pages!
% Otherwise inconsistencies or even
% \textquotedblleft\texttt{undefined}\textquotedblright{-}errors
% would result.\newline
% (This feature was requested by \textsc{Su Mei Goh}.)
%
% \subsection{crop\label{ss:crop}}\index{crop}
% \DescribeMacro{crop}
% To make the thumb marks \textquotedblleft bleed \textquotedblright{} (i.\,e.
% really appear at the edge), they must really extend to the edge of the paper.
% To accomplish this, either a really-to-the-edge-printer is needed or
% after printing cutting the paper right through a part of the thumb marks.
% (Printing houses use paper, which is larger than the desired format,
% and afterwards cut it to format.)
% If you do not want to be left with a smaller paper format,
% you can start with a larger physical page (without changing the page layout!).
% The \xpackage{crop} package is very useful for this. For testing that package,
% you can use A4 paper layout and print on A3 paper;
% for real production probably \textquotedblleft frame \textquotedblright{} would
% be removed from the crop options:
% \begin{verbatim}
% \usepackage[cross,cam,frame,width=297truemm,height=420truemm,center,axes]{crop}[2017/11/19]% v1.10 Crop marks (MF)
% \end{verbatim}
% In contrast to the \textquotedblleft normal \textquotedblright{} example
% the offsets must be regarded for use with the crop package, i.\,e.~ options
% |ignorehoffset=false| and |ignorevoffset=false| should be given to the
% \xpackage{thumbs} package. The example file has been prepared accordingly
% but \xpackage{crop} and the options have been commented out.
%
% \newpage
% \section{Alternatives\label{sec:Alternatives}}\index{Alternatives}
%
% \begin{description}
% \item[-] \xpackage{chapterthumb}, 2005/03/10, v0.1, by \textsc{Markus Kohm}, available at\newline
%  \url{https://mirror.ctan.org/info/examples/KOMA-Script-3/Anhang-B/source/chapterthumb.sty};\newline
%  unfortunately without documentation, which is probably available in the book:\newline
%  \textsc{Kohm}, \textsc{M., \& Morawski}, \textsc{J.-U.} (2012): KOMA-Script -- Die Anleitung.
%  Eine Sammlung von Klassen und Paketen für \LaTeX2e,
%  4.,~überarbeitete und erweiterte Auflage,
%  Lehmanns, Berlin, ISBN:~978-3-86541-459-5,
%  \url{https://www.lehmanns.de/shop/mathematik-informatik/22551854-9783865414595-koma-script-die-anleitung}; in~German.
%
% \item[-] \xpackage{eso-pic}: While version v2.0c 2010/10/06 had issues,
% v3.0c 2023-05-03 might work. It is available at \url{https://ctan.org/pkg/eso-pic}.
%
% \item[-] \xpackage{fancytabs} is available at
%  \url{https://ctan.org/pkg/fancytabs}; does requires \xpackage{TikZ} from the
%  \href{https://ctan.org/pkg/pgf}{pgf} bundle.
%
% \item[-] \xpackage{thumb}, 2001, without file version, by \textsc{Ingo Klöckel},
%  was available at ftp://ftp.dante.de/pub/tex/info/examples/ltt/thumb.sty, \linebreak
%  unfortunately without documentation, which is probably available in the book:\newline
%  \textsc{Klöckel}, \textsc{I.} (2001): \LaTeX2e.\ Tips und Tricks, Dpunkt.Verlag GmbH,
%  ISBN:~978-3-93258-837-2; in~German.
%
% \item[-] \xpackage{thumb} (a completely different one), 1997/12/24, v1.0,
%  by \textsc{Christian Holm}, available at \url{https://ctan.org/pkg/thumb}.
%
% \item[-] \xpackage{thumbindex}, 2009/12/13, without file version, by \textsc{Hisashi Morita},
%  available at \url{https://hisashim.org/2009/12/13/thumbindex.html}.
%
% \item[-] Thumb-indexes, from the \xpackage{fancyhdr} package, available as source code
%  in the documentation of the \xpackage{fancyhdr} package, \url{https://ctan.org/pkg/fancyhdr}.
%
% \item[-] \xpackage{thumbpdf}, 2018-09-07, v3.17, by \textsc{Heiko Oberdiek}, is for creating
%  thumbnails in a \xfile{pdf} document, not thumb marks (and therefore \textit{no} alternative);
%  available at \url{https://ctan.org/pkg/thumbpdf}.
%
% \item[-] \xpackage{thumby}, 2010/01/14, v0.1, by \textsc{Sergey Goldgaber},
%  \textquotedblleft is designed to work with the \href{https://ctan.org/pkg/memoir}{memoir}
%  class, and also requires \href{https://ctan.org/pkg/perltex}{Perl\TeX} and
%  \href{https://ctan.org/pkg/pgf}{tikz}\textquotedblright\ %
%  (\url{https://ctan.org/pkg/thumby}), available at \url{https://ctan.org/pkg/thumby}.
% \end{description}
%
% \bigskip
%
% \noindent Newer versions might be available (and better suited).
% You programmed or found another alternative,
% which is available at \url{CTAN.org}?
% OK, send an e-mail to me with the name, location at \url{CTAN.org},
% and a short notice, and I will probably include it in the list above.
% \newpage
%
% \section{Example}
%    \begin{macrocode}
%<*example>
\documentclass[a4paper,twoside,british]{article}[2025/01/22]% v1.4n Standard LaTeX document class
\usepackage{lipsum}[2021-09-20]%  v2.7 150 paragraphs of Lorem Ipsum dummy text
\usepackage{eurosym}[1998/08/06]% v1.1 European currency symbol ''Euro''
\usepackage[extension=pdf,%
 pdfpagelayout=TwoPageRight,pdfpagemode=UseThumbs,%
 plainpages=false,pdfpagelabels=true,%
 hyperindex=false,%
 pdflang={en},%
 pdftitle={thumbs package example},%
 pdfauthor={H.-Martin Muench},%
 pdfsubject={Example for the thumbs package},%
 pdfkeywords={LaTeX, thumbs, thumb marks},%
 pdfview=Fit,pdfstartview=Fit,%
 linktoc=all]{hyperref}[2025-07-12]% v7.01o Hypertext links for LaTeX
\usepackage[a4paper]{geometry}[2020/01/02]% v5.9 Page Geometry
 % % For testing with package crop,
 % % you can use a4 paper layout and print on a3 paper;
 % % for real production probably "frame" would be removed from the crop options:
 % \usepackage[cross,cam,frame,width=297truemm,height=420truemm,center,axes]{crop}[2017/11/19]% v1.10 Crop marks (MF)
\IfPackageLoadedTF{crop}{%
   % In contrast to the "normal" example  the offsets must be regarded for use with the crop package:
   \PassOptionsToPackage{ignorehoffset=false,ignorevoffset=false}{thumbs}%  crop
 }{\PassOptionsToPackage{ignorehoffset=true,ignorevoffset=true}{thumbs}% no crop
  }
\usepackage[linefill=dots,thumblink=rule,minheight={47pt},height={auto},width={auto},%
            distance={2mm},topthumbmargin={auto},bottomthumbmargin={auto},%
            eventxtindent={5pt},oddtxtexdent={5pt},%
            evenmarkindent={0pt},oddmarkexdent={0pt},evenprintvoffset={0pt},%
            leftindexruleplus={1em},%
            % unused options: frame, frameinnercolor
            txtcentered=false,%
            nophantomsection=false,plainthumbsoverview=false,%
            verbose=true,final=true, hidethumbs=false,%
            % unused, obsolete options:
            %  pagecolor:  instead the pagecolor package is used.
            %  evenindent: was replaced by eventxtindent.
            %  oddexdent:  was replaced by oddtxtexdent.
            ]{thumbs}[2026-01-18]% v1.1d Thumb marks and overview page(s) (HMM)
\nopagecolor% use \pagecolor{white} if \nopagecolor does not work
\IfPackageLoadedF{hyperref}{\usepackage{url}[2013/09/16]% v3.4 Verb mode for urls etc.
}

%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
\DeclareMathAlphabet{\mathup}{OT1}{\familydefault}{m}{n}
\DeclareRobustCommand{\unit}[1]{\ensuremath{\mathord{\thinspace\mathup{#1}}}}

\xdef\thetextchangingcolour{red}
\colorlet{textchangingcolour}{\thetextchangingcolour}

\xdef\themarkchangingcolour{green}
\colorlet{markchangingcolour}{\themarkchangingcolour}

\DeclareRobustCommand{\thethumbchangingtextE}{\Huge{\textbf{E}}}
\DeclareRobustCommand{\thethumbchangingtexte}{\Huge{\textbf{e}}}
\gdef\thumbchangingtext{\thethumbchangingtextE}

\listfiles
\begin{document}
\pagenumbering{arabic}
\label{FirstPage}
\section*{Example for thumbs}
\addcontentsline{toc}{section}{Example for thumbs}
\markboth{Example for thumbs}{Example for thumbs}

This example demonstrates the most common uses of package \textsf{thumbs}, v1.1d as of 2026-01-18.
The used options were\newline
\texttt{linefill=dots}, \texttt{thumblink=rule}, \texttt{minheight=\{47pt\}},
\texttt{height=auto}, \texttt{width={auto}}, \newline
\texttt{distance=\{2mm\}}, \texttt{topthumbmargin=\{auto\}}, \texttt{bottomthumbmargin=\{auto\}}, \newline
\texttt{eventxtindent=\{5pt\}}, \texttt{oddtxtexdent=\{5pt\}},
\texttt{evenmarkindent=\{0pt\}}, \texttt{oddmarkexdent=\{0pt\}}, \newline
\texttt{evenprintvoffset=\{0pt\}},
\texttt{leftindexruleplus=\{1em\}},
\texttt{txtcentered=false}, \newline
\texttt{nophantomsection=false},
\texttt{plainthumbsoverview=false},
\texttt{verbose=true}, \texttt{final=true}, and \newline
\texttt{hidethumbs=false}. \newline

These are the default options, except
\texttt{leftindexruleplus=\{1em\}} (default: \texttt{0pt}) and  \newline
\texttt{verbose=true}.\newline

If package \textsf{crop} was loaded, options
\texttt{ignorehoffset=true} and \texttt{ignorevoffset=true} were passed to the \textsf{thumbs} package,
otherwise \texttt{ignorehoffset=false} and \texttt{ignorevoffset=false}. \newline

Options \texttt{frame} and \texttt{frameinnercolor} were not used.\newline

%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
The obsolete options \texttt{pagecolor} (instead the \texttt{pagecolor} package is used),
\texttt{evenindent} (was replaced by \texttt{eventxtindent}), and
\texttt{oddexdent} (was replaced by \texttt{oddtxtexdent}) were not used. \newline

For more details please see the documentation!\bigskip

\textbf{Hyperlinks or not:} If the \textsf{hyperref} package is loaded,
the references in the overview page for the thumb marks are also hyperlinked
(except when option \texttt{thumblink=none} is used).\bigskip

\noindent\textbf{For testing purpose pages \pageref{greenpage}f. have been completely coloured!}\newline
\textbf{Better exclude those two pages from printing\ldots}\bigskip

Some thumb mark texts are too large for the thumb mark by intention
(especially when the paper size and therefore also the thumb mark size
is decreased). When option \texttt{width=\{autoauto\}} would be used,
the thumb mark width would be automatically increased.
Please see page~\pageref{HugeText} for details!\bigskip

For printing this example to another format of paper (e.\,g.~A4) it is necessary to add the according
option (e.\,g.~\verb|a4paper|) to the document class and recompile it! (In that case the
thumb marks column change will occur at another point, of course.)
With paper format equal to document format the document can be printed without adapting the size,
like e.\,g.~\textquotedblleft shrink to page\textquotedblright . That would add a white border around
the document and by moving the thumb marks from the edge of the paper they no longer appear
at the side of the stack of paper. It is also necessary to use a printer capable of printing up to the
border of the sheet of paper. Alternatively it is possible after the printing to cut the paper to the
right size. While performing this manually is probably quite cumbersome, printing houses use paper,
which is slightly larger than the desired format, and afterwards cut it to format.
\newpage

\addtitlethumb{Frontmatter}{0}{white}{gray}{FirstPage}

At the first page no thumb mark was used, but we want to begin with thumb marks
at the first page, therefore a
\begin{verbatim}
\addtitlethumb{Frontmatter}{0}{white}{gray}{FirstPage}
\end{verbatim}
was used at the beginning of this page. This does not place a thumb mark at that page,
but the pagenumber and link{-}target in the Table of Thumbs point to the first page.
The label \verb|FirstPage| needs to be placed manually on the first page, of course!
If manually no label can be placed on the first page, the label \texttt{pagesLTS.0}
from the \textsf{pageslts} package (needs to be loaded explicitly!) can be used.
\newpage
\tableofcontents
\newpage

To include an overview page for the thumb marks,
\begin{verbatim}
\addthumbsoverviewtocontents{section}{Thumb marks overview}%
\thumbsoverview{Table of Thumbs}%
\end{verbatim}
is used, where \verb|\addthumbsoverviewtocontents| adds the thumb marks overview page to the table of contents.
(\textquotedblleft Edge index\textquotedblright{} would be the correct/{}formal term, see the Introduction in the manual.)
\smallskip

Generally it is desirable to have a hyperlink from the thumbs overview page to lead to the thumb mark
and not to some earlier place. Therefore automatically a~\verb|\phantomsection| is placed before each thumb mark.
But for example when using the thumb mark after a~\verb|\chapter{...}| command, it is probably nicer to have
the link point at the top of that chapter's title (instead of the line below it). The automatic placing of the
\verb|\phantomsection| can be disabled either globally by using option \texttt{nophantomsection},
or locally for the next thumb mark by the command \verb|\thumbsnophantom|. (When disabled globally,
still manual use of \verb|\phantomsection| is possible.)

\addthumbsoverviewtocontents{section}{Thumb marks overview}%
\thumbsoverview{Table of Thumbs}%

\noindent Those were the overview pages for the thumb marks.
\newpage

\section{The first section}
\addthumb{First section}{%
\space\Huge{\textbf{$1\textsuperscript{st}$}}}{yellow}{green}

\begin{verbatim}
\addthumb{First section}{%
\space\Huge{\textbf{$1\textsuperscript{st}$}}}{yellow}{green}
\end{verbatim}

A thumb mark is added for this section. The parameters are: title for the thumb mark,
the text to be displayed in the thumb mark (choose your own format),
the colour of the text in the thumb mark,
and the background colour of the thumb mark (parameters in this order).\newline

Now for some pages of \textquotedblleft content\textquotedblright\ldots

\newpage
\lipsum[1]
\newpage
\lipsum[1]
\newpage
\lipsum[1]
\newpage

\section{The second section}
\addthumb{Second section}{\Huge{\textbf{\arabic{section}}}}{green}{yellow}

For this section, the text to be displayed in the thumb mark was set to
\begin{verbatim}
\Huge{\textbf{\arabic{section}}}
\end{verbatim}
i.\,e. the number of the section will be displayed (huge \& bold).\newline

Let us change the thumb mark on a page with an even number:
\newpage

\section{The third section}
\addthumb{Third section}{\Huge{\textbf{\arabic{section}}}}{blue}{red}

No problem!

And you do not need to have a section to add a thumb:
\newpage

\addthumb{Still third section}{\Huge{\textbf{\arabic{section}b}}}{red}{blue}

This is still the third section, but there is a new thumb mark.

On the other hand, you can even get rid of the thumb marks for some page(s):
\newpage

\stopthumb

\noindent The command
\begin{verbatim}
\stopthumb
\end{verbatim}
was used here. Until another \verb|\addthumb| (with parameters) or
\begin{verbatim}
\continuethumb
\end{verbatim}
is used, there will be no more thumb marks.
\newpage
Still no thumb marks.\newpage
Still no thumb marks.\newpage
Still no thumb marks.\newpage

%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
\continuethumb

Thumb mark continued (unchanged).\newpage
Thumb mark continued (unchanged).\newpage

Time for another thumb,

\addthumb{Another heading}{Small text}{white}{black}

and another.\bigskip

\addthumb{Huge Text paragraph}{\Huge{Huge\newline Text}}{yellow}{green}

\textquotedblleft {\Huge{Huge Text}}\textquotedblright\ is too wide for the thumb mark. When option
\texttt{width=\{autoauto\}} would be used, the thumb mark width would be automatically increased.
Now the text is either split over two lines (try \verb|Huge\newline Text| for another format)
or (in case \verb|Huge~Text| is used) is written over the border of the thumb mark. When the text is
too wide for the thumb mark and cannot be split, \LaTeX{} might nevertheless place the text into the
next line. By this the text is placed too low. Adding a
\hbox{\verb|\protect\vspace*{-| some length \verb|}|} to the text could help, for example\newline
\verb|\addthumb{Huge Text}{\protect\vspace*{-3pt}\Huge{Huge~Text}}...|.\label{HugeText}\bigskip

\addthumb{Huge Text}{\Huge{Huge~Text}}{red}{blue}
\addthumb{Huge Bold Text}{\Huge{\textbf{HBT}}}{black}{yellow}

\noindent When there is more than one thumb mark at one page, this is also no problem.\newpage
Some text\newpage
Some text\newpage
Some text\newpage

\section{xcolor}
\addthumb{xcolor}{\Huge{\textbf{xcolor}}}{magenta}{cyan}

It is probably a good idea to have a look at the \textsf{xcolor} package and use other colours than used
in this example.\newline
(About automatically increasing the thumb mark width to the thumb mark text width please see the note
at page~\pageref{HugeText}.)
\newpage

\addthumb{A mark}{\Huge{\textbf{A}}}{lime}{darkgray}

I just need to add further thumb marks to get them reaching the bottom of the page.\newline
Generally the vertical size of the thumb marks is set to the value given in the height option.
If it is \texttt{auto}, the size of the thumb marks is decreased, so that they fit all on one page.
But when they get smaller than \texttt{minheight}, instead of decreasing their size further,
a~new thumbs column is started (which will happen here).
\newpage

\addthumb{B mark}{\Huge{\textbf{B}}}{brown}{pink}

Another thumb mark.\newpage

\addthumb{C mark}{\Huge{\textbf{C}}}{brown}{pink}

There! A new thumb column was started automatically!

On the one hand you can, of course, keep the colour for more than one thumb mark.
On the other hand you can change the colour of an existing thumb mark,
shown at page~\pageref{E mark}f.\newpage

\addthumb{$1/1.\,955\,83$\, EUR}{\Huge{\textbf{D}}}{orange}{violet}

\noindent I am just adding further thumb marks.

\noindent If you are curious why the thumb mark between
\textquotedblleft C mark\textquotedblright\ and \textquotedblleft E mark\textquotedblright\ has
not been named \textquotedblleft D mark\textquotedblright\ but
\textquotedblleft $1/1.\,955\,83$\, EUR\textquotedblright :

$1\unit{DM}=1\unit{D\ Mark}=1\unit{Deutsche\ Mark}%
=\frac{1}{1.\,955\,83}\,$\euro$\,=1/1.\,955\,83\unit{Euro}=1/1.\,955\,83\unit{EUR}$.
\newpage
Just a page.
\newpage

\xdef\thetextchangingcolour{red}%
\colorlet{textchangingcolour}{\thetextchangingcolour}%

\xdef\themarkchangingcolour{green}%
\colorlet{markchangingcolour}{\themarkchangingcolour}%

  %% In the preamble:
  %%\DeclareRobustCommand{\thethumbchangingtextE}{\Huge{\textbf{E}}}
  %%\DeclareRobustCommand{\thethumbchangingtexte}{\Huge{\textbf{e}}}
  %%\gdef\thumbchangingtext{\thethumbchangingtextE}

\gdef\thumbchangingtext{\thethumbchangingtextE}%

\addthumb{E mark}{\protect\thumbchangingtext}{textchangingcolour}{markchangingcolour}
\label{E mark}

%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
As announced above, it is not only possible to keep the colour for more than one thumb mark,
but also to change the colour(s) and the text of an existing thumb mark. Here a thumb mark added with
\begin{verbatim}
\addthumb{Name}{\protect\thumbchangingtext}{textchangingcolour}{%
markchangingcolour}
\end{verbatim}
appears as red text \textquotedblleft E\textquotedblright{} on green background,
but really it is not \texttt{red} but \texttt{textchangingcolour} (which was defined as \texttt{red})
and not \texttt{green} but\newline
\texttt{markchangingcolour} (which was defined as \texttt{green}). Also the text of a thumb mark
can be changed. Here \verb|thumbchangingtext| was used as text, which was defined as
\verb|thethumbchangingtextE|, which was predefined in the preamble:
\begin{verbatim}
\DeclareRobustCommand{\thethumbchangingtextE}{\Huge{\textbf{E}}}
\end{verbatim}
\newpage

\noindent Some pages(s) later:

\begin{verbatim}
\xdef\thetextchangingcolour{blue}%
\colorlet{textchangingcolour}{\thetextchangingcolour}%

\xdef\themarkchangingcolour{yellow}%
\colorlet{markchangingcolour}{\themarkchangingcolour}%

\gdef\thumbchangingtext{\thethumbchangingtexte}%
\end{verbatim}

\xdef\thetextchangingcolour{blue}%
\colorlet{textchangingcolour}{\thetextchangingcolour}%

\xdef\themarkchangingcolour{yellow}%
\colorlet{markchangingcolour}{\themarkchangingcolour}%

\gdef\thumbchangingtext{\thethumbchangingtexte}%

And here the thumb mark still uses \texttt{textchangingcolour} and\newline
\texttt{markchangingcolour}, but instead of \texttt{red} and \texttt{green}
those have been redefined to \texttt{blue} and \texttt{yellow}.
\verb|\thumbchangingtext| was still used as text, but redefined as \verb|\thethumbchangingtexte|,
which was predefined in the preamble:
\begin{verbatim}
\DeclareRobustCommand{\thethumbchangingtexte}{\Huge{\textbf{e}}}
\end{verbatim}
%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
Instead of \verb|\thumbchangingtext| also some variable like \verb|\thepage| can be used.\newline
For the thumb marks overview page(s) it must be decided which colour(s) and text
to use and the according definitions have to be made before that page{/}those pages!
Otherwise inconsistencies or even \textquotedblleft\texttt{undefined}\textquotedblright{-}errors
would result.
\newpage
(This page was intentionally left blank.)
\newpage

To prevent inconsistencies between the different thumb mark overviews,
we redefine \texttt{textchangingcolour} to \texttt{red},
\texttt{markchangingcolour} to \texttt{green}, and
\verb|\thumbchangingtext| to \verb|\thethumbchangingtextE| again here.

\xdef\thetextchangingcolour{red}%
\colorlet{textchangingcolour}{\thetextchangingcolour}%

\xdef\themarkchangingcolour{green}%
\colorlet{markchangingcolour}{\themarkchangingcolour}%

\gdef\thumbchangingtext{\thethumbchangingtextE}%

\newpage

\makeatletter%
\ifx\thumbs@frame\thumbs@empty\relax%
  \gdef\thumbs@frame{2pt}%
  \gdef\th@mbs@fr@meinnercolor{\thepagecolor}% could also be another colour
  \gdef\thumbs@checkforexample{0}%
\else% somebody changed the example to use the frame option:
  \gdef\thumbs@checkforexample{1}%
  \PackageInfo{thumbs}{The frame option is already used,\MessageBreak%
                                    not changing here anything!}%
\fi%
\makeatother%

\textsc{Bjorn Victor} suggested to use thumb marks consisting only of frames
instead of filled rectangles. Options \texttt{frame} and \texttt{frameinnercolor} were introduced
to accomplish this. While these options have not been used in this example, it is possible to trick
\LaTeX{} into believing that they had been used. (Do not use this for a regular document!)
This is just for demonstrating how a thumb mark consisting just of a frame with
$2\unit{pt}$~thick lines would look like\newpage
\noindent on left and right pages.\newpage

Now let us restore the filled thumb marks again

\makeatletter%
\ifx\thumbs@checkforexample\thumbs@zero\relax%
  \gdef\thumbs@frame{\empty}%
  \gdef\th@mbs@fr@meinnercolor{\thepagecolor}%
%\else Somebody changed the example to use the frame option!
\fi%
\makeatother%

and then have a look at \verb|\thumbsoverviewverso|:

\addthumbsoverviewtocontents{section}{Table of Thumbs, verso mode}%
\thumbsoverviewverso{Table of Thumbs, verso mode}

\newpage

And, of course, also at \verb|\thumbsoverviewdouble|:

\addthumbsoverviewtocontents{section}{Table of Thumbs, double mode}%
\thumbsoverviewdouble{Table of Thumbs, double mode}

\newpage

\addthumb{F mark}{\Huge{\textbf{F}}}{lightgray}{black}

I am just adding further thumb marks.
\newpage

\addthumb{G mark}{\Huge{\textbf{G}}}{magenta}{black}

Some text.

\newpage
\thumbnewcolumn
\addthumb{New thumb marks column}{\Huge{\textit{NC}}}{magenta}{black}

There! A new thumb column was started manually!

\newpage
Some text.
\newpage

\addthumb{H mark}{\Huge{\textbf{H}}}{orange}{violet}

I just added another thumb mark.
\newpage
The following two pages are completely coloured in green.
\newpage
\pagecolor{green}

\IfPackageLoadedT{hyperref}{\phantomsection}
\label{greenpage}

Some faulty, outdated version of a pdf-viewer sometimes (for the same document!)
added a white line at the bottom and right side of the document when presenting it. This did
not change the printed version. To test for this problem, this doublepage has been completely coloured.
(Probably better exclude these two pages from printing!)\newline

\textsc{Heiko Oberdiek} wrote at Tue, 26 Apr 2011 14:13:29 +0200 in the \newline
comp.text.tex newsgroup (see e.\,g.\newline
\url{https://groups.google.com/g/de.comp.text.tex/c/4GAcL6qlTZ8/m/NzccDqakrrMJ}):\newline
\textquotedblleft Der Ursprung ist 0 0, da gibt es nicht viel zu runden; bei den anderen
Seiten werden pt als bp in die PDF-Datei geschrieben, d.\,h.~der Balken ist um 72.27/72 zu
gro\ss{}, das sollte auch Rundungsfehler abdecken.\textquotedblright\newline

(The origin is 0 0, there is not much to be rounded; for the other sides the $\unit{pt}$
are written as $\unit{bp}$ into the pdf-file, i.\,e.~the rule is too large by $72.27/72$,
which should cover also rounding errors.)\newline

The thumb marks are also too wide -- on purpose! This has been done to assure,
that they cover the page up to its (paper) border, therefore they are placed
a little bit over the paper margin.\newline

Now I red somewhere in the net (should have remembered to note the url),
that white margins are presented, whenever there is some object outside of the page.
Thus, it is a feature, not a bug?!
What I do not understand: The same document sometimes is presented
with white lines and sometimes without (same viewer, same PC).\newline
But at least it does not influence the printed version.
\newpage
Another green page.
\newpage
\pagecolor{white}

It is possible to use the Table of Thumbs more than once (for example at the beginning and
at the end of the document) and to refer to them via e.\,g.~\verb|\pageref{TableOfThumbs1}|,\linebreak
\verb|\pageref{TableOfThumbs2}|,\ldots , here: page~\pageref{TableOfThumbs1},
page~\pageref{TableOfThumbs2}, and via e.\,g.~\verb|\pageref{TableOfThumbs}|
it is referred to the last used Table of Thumbs (for compatibility with older package versions).
If there is only one Table of Thumbs, this one is also the last one, of course.
Here it is at page~\pageref{TableOfThumbs}.\newline

%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
Now let us have a look at \verb|\thumbsoverviewback|:

\addthumbsoverviewtocontents{section}{Table of Thumbs, back mode}%
\thumbsoverviewback{Table of Thumbs, back mode}%
\newpage

Text can be placed after any of the Tables of Thumbs, of course.
\end{document}
%</example>
%    \end{macrocode}
% \StopEventually{}
% \newpage
%
% \section{The implementation}
% We start off by checking that we are loading into \LaTeXe{} and
% announcing the name and version of this package.
%
%    \begin{macrocode}
%<*package>
%    \end{macrocode}
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[2025/06/01]
\@ifl@t@r\fmtversion{2025/06/01}{% would have understood
 % \IfFormatAtLeastTF{2025-06-01}{<true code>}{<false code>}
 }{\PackageError{thumbs}{Newer LaTeX format needed or older thumbs package}{%
     Needed LaTeX format version: 2025-06-01 or newer.\MessageBreak%
     Found\space\space LaTeX format version: \fmtversion.\MessageBreak%
     Either update your TeX distribution\MessageBreak%
     or use an archived version of thumbs\MessageBreak%
     (see section History in the documentation).}
  }
\ProvidesPackage{thumbs}[2026-01-18 v1.1d Thumb marks and overview page(s) (HMM)]

%    \end{macrocode}
%
% A short description of the \xpackage{thumbs} package:
%
%    \begin{macrocode}
%% This package allows to create a customizable thumb index (edge index),
%% providing a quick and easy reference method for large documents,
%% as well as one or several overview page(s).

%    \end{macrocode}
%
% Several packages are needed (see subsection~\ref{ss:Downloads}):
%
%    \begin{macrocode}
\RequirePackage{xcolor}[2024/09/29]%         v3.02 LaTeX color extensions (UK)
\RequirePackage{picture}[2020-04-22]%        v1.6  Dimens for picture macros (HO)
\RequirePackage{alphalph}[2019/12/09]%       v2.6  Convert numbers to letters (HO)
\RequirePackage{rerunfilecheck}[2025-06-21]% v1.11 Rerun checks for auxiliary files (HO)
\RequirePackage{pagecolor}[2025-01-28]%      v1.2d Provides thepagecolor (HMM)
\RequirePackage{undolabl}[2025-01-28]%       v1.0o Overriding labels (HMM)
%    \end{macrocode}
%
% The \xpackage{undolabl} package is needed for |\overridelabel|.
%
% The options are introduced, where the obsolete options
% |pagecolor| (use |\pagecolor{...}| after |\usepackage[...]{thumbs}| and before |\begin{document}|
% to define a background colour of the pages),
% |evenindent| (was renamed to |eventxtindent|) and
% |oddexdent| (was renamed to |oddtxtexdent|)
% have been removed:
%
%    \begin{macrocode}

\DeclareKeys[thumbs]{
  % OBSOLETE: pagecolor  -> use \pagecolor{...} after \usepackage[...]{thumbs} and before \begin{document}
  % OBSOLETE: evenindent -> eventxtindent
  % OBSOLETE: oddexdent  -> oddtxtexdent
  linefill          .store = \thumbs@linefill,
  thumblink         .store = \thumbs@thumblink,
  minheight         .store = \thumbs@minheight,
  height            .store = \thumbs@height,
  width             .store = \thumbs@width,
  distance          .store = \thumbs@distance,
  topthumbmargin    .store = \thumbs@topthumbmargin,
  bottomthumbmargin .store = \thumbs@bottomthumbmargin,
  eventxtindent     .store = \thumbs@eventxtindent,
  oddtxtexdent      .store = \thumbs@oddtxtexdent,
  evenmarkindent    .store = \thumbs@evenmarkindent,
  oddmarkexdent     .store = \thumbs@oddmarkexdent,
  evenprintvoffset  .store = \thumbs@evenprintvoffset,
  leftindexruleplus .store = \thumbs@leftindexruleplus,
  frame             .store = \thumbs@frame,
  frameinnercolor   .store = \thumbs@frameinnercolor,
  txtcentered         .if = thumbs@txtcentered,
  ignorehoffset       .if = thumbs@ignorehoffset,
  ignorevoffset       .if = thumbs@ignorevoffset,
  nophantomsection    .if = thumbs@nophantomsection,
  plainthumbsoverview .if = thumbs@plainthumbsoverview,
  verbose             .if = thumbs@verbose,
  silent              .code = \thumbs@verbosefalse,
  draft               .if = thumbs@draft,
  final               .code = \thumbs@draftfalse,
  hidethumbs          .if = thumbs@hidethumbs,
  righttoleft         .if = thumbs@righttoleft
}

\SetKeys[thumbs]{
  linefill          = dots,
  thumblink         = rule,
  minheight         = 47pt,
  height            = auto,
  width             = auto,
  distance          = 2mm,
  topthumbmargin    = auto,
  bottomthumbmargin = auto,
  eventxtindent     = 5pt,
  oddtxtexdent      = 5pt,
  evenmarkindent    = 0pt,
  oddmarkexdent     = 0pt,
  evenprintvoffset  = 0pt,
  leftindexruleplus = 0pt,
  frame             = \empty,
  frameinnercolor   = \thepagecolor,
  txtcentered       = false,
  ignorehoffset     = true,
  ignorevoffset     = true,
  verbose           = true,
  hidethumbs        = false,
  righttoleft       = false
}

\ProcessKeyOptions[thumbs]

%    \end{macrocode}
%
% For determining on which page we are, we use the counter |ThumbsPage|:
%
%    \begin{macrocode}
\newcounter{ThumbsPage}
\setcounter{ThumbsPage}{1}
\AddToHook{shipout/foreground}{\addtocounter{ThumbsPage}{1}}

%    \end{macrocode}
%
% The (background) page colour is set to |\thepagecolor| (from the \xpackage{pagecolor} package),
% because the \xpackage{xcolour} package needs a defined colour here (it~can be changed later).
%
%    \begin{macrocode}
\pagecolor{\thepagecolor}

%    \end{macrocode}
%
% \DescribeMacro{ignorehoffset}
% \DescribeMacro{ignorevoffset}\index{crop}
% Usually |\hoffset| and |\voffset| should be regarded, but moving the thumb marks away
% from the paper edge probably makes them useless. Therefore |\hoffset| and |\voffset|
% are ignored by default, or when option |ignorehoffset| or |ignorehoffset=true| is used
% (and |ignorevoffset| or |ignorevoffset=true|, respectively).  But in case that the user
% wants to print at one sort of paper but later trim it to another one, regarding
% the offsets would be necessary. This is the case especially when using the
% \xpackage{crop} package. Therefore |ignorehoffset=false| and |ignorevoffset=false| can
% be used to regard these offsets.
% (Combinations |ignorehoffset=true, ignorevoffset=false| and
% |ignorehoffset=false, ignorevoffset=true| are also possible.)
%
%    \begin{macrocode}
\ifthumbs@ignorehoffset
  \PackageInfo{thumbs}{%
    Option ignorehoffset NOT =false:\MessageBreak%
    hoffset will be ignored.\MessageBreak%
    To make thumbs regard hoffset\MessageBreak%
    (for example when using the crop package)\MessageBreak%
    use option ignorehoffset=false\@gobble}
  \gdef\th@bmshoffset{0sp}
\else
  \PackageInfo{thumbs}{%
    Option ignorehoffset=false:\MessageBreak%
    hoffset will be regarded.\MessageBreak%
    This might move the thumb marks\MessageBreak%
    horizontally away from the physical paper edge\MessageBreak%
    (which should be done e.g. when using the crop package)\@gobble}
  \gdef\th@bmshoffset{\hoffset}
\fi

%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
\ifthumbs@ignorevoffset
  \PackageInfo{thumbs}{%
    Option ignorevoffset NOT =false:\MessageBreak%
    voffset will be ignored.\MessageBreak%
    To make thumbs regard voffset\MessageBreak%
    (for example when using the crop package)\MessageBreak%
    use option ignorevoffset=false\@gobble}
  \gdef\th@bmsvoffset{0sp}
\else
  \PackageInfo{thumbs}{%
    Option ignorevoffset=false:\MessageBreak%
    voffset will be regarded.\MessageBreak%
    This might move the thumb marks\MessageBreak%
    vertically away from the physical paper edge\MessageBreak%
    (which should be done e.g. when using the crop package)\@gobble}
  \gdef\th@bmsvoffset{\voffset}
\fi

%    \end{macrocode}
%
% \DescribeMacro{frameinnercolor}
% |\thumbs@empty| is later needed for comparisons.~--
% The |frameinnercolor| option gives the colour to fill the frame with,
% if the thumb marks are not to be drawn filled but only as frame.
% The \textquotedblleft colour\textquotedblright{} is usually
% |\thepagecolor| or |white|, but flexibility is given to the user.
% The colour to be used is initialised as |\thepagecolor|,
% because nothing shall be drawn when no thumb mark is requested
% (but really an empty thumb mark is drawn, thus it must be made
% \textquotedblleft invisible\textquotedblright ).
%
%    \begin{macrocode}
\gdef\thumbs@empty{\empty}
\gdef\th@mbs@fr@meinnercolor{\thepagecolor}

%    \end{macrocode}
%
% \DescribeMacro{linefill}
% We process the |linefill| option value:
%
%    \begin{macrocode}
\ifx\thumbs@linefill\empty%
  \gdef\th@mbs@linefill{\hspace*{\fill}}
\else
  \def\th@mbstest{line}
  \ifx\thumbs@linefill\th@mbstest%
    \gdef\th@mbs@linefill{\hrulefill}
  \else
    \def\th@mbstest{dots}
    \ifx\thumbs@linefill\th@mbstest%
      \gdef\th@mbs@linefill{\dotfill}
    \else
      \PackageError{thumbs}{Option linefill with invalid value}{%
        Option linefill has value "\thumbs@linefill ".\MessageBreak%
        Valid values are "" (empty), "line", or "dots".\MessageBreak%
        "" (empty) will be used now.}
       \gdef\th@mbs@linefill{\hspace*{\fill}}
    \fi
  \fi
\fi

%    \end{macrocode}
%
% We introduce new dimensions for width, height, position of and vertical distance
% between the thumb marks and some helper dimensions.
%
%    \begin{macrocode}
\newdimen\th@mbwidthx

\newdimen\th@mbheighty% Thumb height y
\setlength{\th@mbheighty}{\z@}

\newdimen\th@mbposx
\newdimen\th@mbposy
\newdimen\th@mbposyA
\newdimen\th@mbposyB
\newdimen\th@mbposytop
\newdimen\th@mbposybottom
\newdimen\th@mbwidthxtoc
\newdimen\th@mbwidthtmp
\newdimen\th@mbsposytocy
\newdimen\th@mbsposytocyy
\newdimen\th@mbirulex
\newdimen\th@mbiruley

%    \end{macrocode}
%
% Horizontal indentation of thumb marks text on odd/even pages according to the chosen options:
%
%    \begin{macrocode}
\newdimen\th@mbHitO
\setlength{\th@mbHitO}{\thumbs@oddtxtexdent}
\newdimen\th@mbHitE
\setlength{\th@mbHitE}{\thumbs@eventxtindent}

%    \end{macrocode}
%
% Horizontal indentation of whole thumb marks on odd/even pages according to the chosen options:
%
%    \begin{macrocode}
\newdimen\th@mbHimO
\setlength{\th@mbHimO}{\thumbs@oddmarkexdent}
\newdimen\th@mbHimE
\setlength{\th@mbHimE}{\thumbs@evenmarkindent}

%    \end{macrocode}
%
% Vertical distance between thumb marks on odd/even pages according to the chosen option:
%
%    \begin{macrocode}
\newdimen\th@mbsdistance
\ifx\thumbs@distance\empty%
  \setlength{\th@mbsdistance}{1mm}
\else
  \setlength{\th@mbsdistance}{\thumbs@distance}
\fi

%    \end{macrocode}
%
% Handling of option |leftindexruleplus|, see page~\pageref{sss:leftindexruleplus}:
%
%    \begin{macrocode}
\newdimen\th@mbslirplus
\ifx\thumbs@leftindexruleplus\empty%
  \setlength{\th@mbslirplus}{\z@}
\else
  \setlength{\th@mbslirplus}{\thumbs@leftindexruleplus}
\fi

%    \end{macrocode}
%
% Option |verbose| (or complementary option |silent|):
%
%    \begin{macrocode}
\ifthumbs@verbose\else
  \PackageInfo{thumbs}{%
    Option verbose=false (or silent=true) found:\MessageBreak%
    You will lose some information in the log file\@gobble}
\fi

%    \end{macrocode}
%
% We create a new |Box| for the thumbs and make some global definitions.
%
%    \begin{macrocode}
\newbox\ThumbsBox

\gdef\th@mbs{0}
\gdef\th@mbsmax{0}
\gdef\th@umbsperpage{0}% will be set via .aux file
\gdef\th@umbsperpagecount{0}

\gdef\th@mbtitle{}
\gdef\th@mbtext{}
\gdef\th@mbtextcolour{\thepagecolor}
\gdef\th@mbbackgroundcolour{\thepagecolor}
\gdef\th@mbcolumn{0}

\gdef\th@mbtextA{}
\gdef\th@mbtextcolourA{\thepagecolor}
\gdef\th@mbbackgroundcolourA{\thepagecolor}

\gdef\th@mbprinting{1}
\gdef\th@mbtoprint{0}
\gdef\th@mbonpage{0}
\gdef\th@mbonpagemax{0}

\gdef\th@mbcolumnnew{0}

\gdef\th@mbs@toc@level{}
\gdef\th@mbs@toc@text{}

\gdef\th@mbmaxwidth{\z@}

\gdef\th@mb@titlelabel{}

\gdef\th@mbstable{0}% number of thumb marks overview tables (edge indexes)

%    \end{macrocode}
%
% For comparisons, zero, one, and two are defined (|\z@|, |\@ne| and so on do not work for this):
%
%    \begin{macrocode}
\def\thumbs@zero{0}
\def\thumbs@one{1}
\def\thumbs@two{2}

%    \end{macrocode}
%
% |\th@mbpofffix| is short for \textquotedblleft page number offset fix\textquotedblright{}
% (see page~\pageref{Labelpofffix}):
%
%    \begin{macrocode}
\xdef\th@mbpofffix{-1}% page number offset fix

%    \end{macrocode}
%
% If the \xpackage{crop}\index{crop} package is used to print (with unchanged layout)
% on a larger format of paper, \xpackage{crop} must be loaded before \xpackage{thumbs}.
% (When testing, even the inverse order worked, but better not rely on it.)
%
%    \begin{macrocode}
\IfPackageLoadedTF{crop}{\gdef\th@mbcrop{1}}{\gdef\th@mbcrop{0}}
\AddToHook{enddocument/info}[kernel/warnings]{%
  \IfPackageLoadedT{crop}{\ifx\th@mbcrop\thumbs@zero\relax%
  \PackageError{thumbs}{Package crop loaded *after* package thumbs}{%
    When package crop shall be used,\MessageBreak%
    it must be loaded *before* package thumbs,\MessageBreak%
    but it was loaded *afterwards*!}%
  \fi}%
  }

%    \end{macrocode}
%
% After issues with |\@tempcnta|, and because the \eTeX{} extensions are available since 1999
% and \eTeX{} is included in all modern distributions,
% I~decided to give two new counters to the \xpackage{thumbs} package.
%
%    \begin{macrocode}
\newcounter{Th@mbTmpA}
\newcounter{Th@mbTmpB}

%    \end{macrocode}
%
% We define a new length |\th@mbcomprulewidth| and set it to the
% sum of |\th@mbwidthx| and |\th@mbruleoutside|.
%
%    \begin{macrocode}
\newdimen\th@mbcomprulewidth
\newdimen\th@mbruleoutside
\setlength{\th@mbruleoutside}{6cm}
\setlength{\th@mbcomprulewidth}{\dimexpr\th@mbwidthx+\th@mbruleoutside\relax}

%    \end{macrocode}
%
% \pagebreak
% It is checked whether writing to \jobname.tmb is allowed.
%
%    \begin{macrocode}
\if@filesw\else
  \PackageWarningNoLine{thumbs}{No auxiliary files allowed!\MessageBreak%
    It was not allowed to write to files.\MessageBreak%
    A lot of packages do not work without access to files\MessageBreak%
    like the .aux one. The thumbs package needs to write\MessageBreak%
    to the \jobname.tmb file. To exit press\MessageBreak%
    Ctrl+Z\MessageBreak%
    .\MessageBreak}
\fi

%    \end{macrocode}
%
%    \begin{macro}{\th@mb@txtBox}
% |\th@mb@txtBox| writes its second argument (most likely |\th@mb@tmp@text|)
% in normal text size. Sometimes another text size could
% \textquotedblleft leak\textquotedblright{} from the respective page,
% |\normalsize| prevents this. If another text size is whished for,
% it can always be changed inside |\th@mb@tmp@text|.
% The colour given in the first argument (most likely |\th@mb@tmp@textcolour|)
% is used and either |center|ed (depending on the |txtcentered| option) or
% |\raggedleft| or |\raggedright| (depending on the third argument).
% The forth argument determines the width of the |\parbox|.
% Centering is a little bit difficult:
%
%    \begin{macrocode}
\newcommand{\th@mb@txtBox}[4]{%
  \setlength{\th@mbwidthtmp}{#4}%
  \ifthumbs@txtcentered%
    \addtolength{\th@mbwidthtmp}{3pt}%
    \ifodd\c@Th@mbTmpA\relax%
      \hspace*{+\th@mbHitO}%
    \else%
      \if@twoside%
        \hspace*{-\th@mbHitE}%
      \else%
        \hspace*{+\th@mbHitO}%
      \fi%
    \fi%
  \fi%
  \parbox[c][\th@mbheighty][c]{\th@mbwidthtmp}{%
    \settowidth{\th@mbwidthtmp}{\normalsize{#2}}%
    \addtolength{\th@mbwidthtmp}{-#4}%
    \ifthumbs@txtcentered%
      {\begingroup{\begin{center}{\color{#1}\normalsize{#2}}\end{center}}\endgroup}%
    \else%
%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
      \def\th@mbstest{#3}%
      \def\th@mbstestb{r}%
      \ifx\th@mbstest\th@mbstestb%
         \ifdim\th@mbwidthtmp >0sp\relax\hspace*{-\th@mbwidthtmp}\fi%
         {\raggedleft\leftskip 0sp minus \textwidth{\hfill\color{#1}\normalsize{#2}}}%
      \else% \th@mbstest = l
        {\raggedright{\color{#1}\normalsize{\hspace*{1pt}\space{#2}}}}%
      \fi%
    \fi%
    }%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\setth@mbheight}
% In |\setth@mbheight| the height of a thumb mark (for automatic thumb heights) is computed as\newline
% \textquotedblleft |((Thumbs extension) / (Number of Thumbs)) - (2|%
% $\times $\ |distance between Thumbs)|\textquotedblright.
%
%    \begin{macrocode}
\newcommand{\setth@mbheight}{%
  \setlength{\th@mbheighty}{\z@}%
  \addtolength{\th@mbheighty}{\headheight}%
  \addtolength{\th@mbheighty}{\headsep}%
  \addtolength{\th@mbheighty}{\textheight}%
  \addtolength{\th@mbheighty}{\footskip}%
  \setcounter{Th@mbTmpA}{\th@mbsmax}%
  \ifnum\c@Th@mbTmpA>1\relax%
    \divide\th@mbheighty\th@mbsmax%
  \fi%
  \addtolength{\th@mbheighty}{-\th@mbsdistance}%
  \addtolength{\th@mbheighty}{-\th@mbsdistance}%
  }

%    \end{macrocode}
%    \end{macro}
%
% At the beginning of the document the hook |begindocument| is executed.
% |\th@bmshoffset| and |\th@bmsvoffset| are set again,
% because |\hoffset| and |\voffset| could have been changed.
%
%    \begin{macrocode}
\AddToHook{begindocument}[start]{%
  \ifthumbs@ignorehoffset%
    \gdef\th@bmshoffset{0sp}%
  \else%
    \gdef\th@bmshoffset{\hoffset}%
  \fi%
  \ifthumbs@ignorevoffset%
    \gdef\th@bmsvoffset{0sp}%
  \else%
    \gdef\th@bmsvoffset{\voffset}%
  \fi%
  \xdef\th@mbpaperwidth{\the\paperwidth}%
  \setlength{\@tempdima}{1pt}%
%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
  \ifdim \thumbs@minheight < \@tempdima% too small
    \setlength{\thumbs@minheight}{1pt}%
  \else%
    \ifdim \thumbs@minheight = \@tempdima% small, but ok
    \else%
      \ifdim \thumbs@minheight > \@tempdima% ok
      \else%
        \PackageError{thumbs}{Option minheight has invalid value}{%
          As value for option minheight please use\MessageBreak%
          a number and a length unit (e.g. mm, cm, pt)\MessageBreak%
          and no space between them\MessageBreak%
          and include this value+unit combination in curly brackets\MessageBreak%
          (please see the thumbs-example.tex file).\MessageBreak%
          When pressing Return, minheight will now be set to 47pt.}%
        \setlength{\thumbs@minheight}{47pt}%
      \fi%
    \fi%
  \fi%
  \setlength{\@tempdima}{\thumbs@minheight}%
%    \end{macrocode}
%
% Thumb height |\th@mbheighty| is treated. If the value is empty,
% it is set to |\@tempdima|, which was just defined to be $47\unit{pt}$
% (by default), or to the value chosen by the user with package option
% |minheight={...}|:
%
%    \begin{macrocode}
  \ifx\thumbs@height\empty%
    \setlength{\th@mbheighty}{\@tempdima}%
  \else%
    \def\th@mbstest{auto}%
    \ifx\thumbs@height\th@mbstest%
%    \end{macrocode}
%
% If it is not empty but \texttt{auto}(matic), the value is computed
% via |\setth@mbheight| (see above).
%
%    \begin{macrocode}
      \setth@mbheight%
%    \end{macrocode}
%
% When the height is smaller than |\thumbs@minheight| (default: $47\unit{pt}$),
% this is too small, and instead a now column/page of thumb marks is used.
%
%    \begin{macrocode}
      \ifdim \th@mbheighty < \thumbs@minheight%
        \PackageWarningNoLine{thumbs}{Thumbs not high enough:\MessageBreak%
          Option height has value "auto". For \th@mbsmax\space thumbs per page\MessageBreak%
          this results in a thumb height of \the\th@mbheighty.\MessageBreak%
          This is lower than the minimal thumb height, \thumbs@minheight,\MessageBreak%
          therefore another thumbs column will be opened.\MessageBreak%
          If you do not want this, choose a smaller value\MessageBreak%
          for option "minheight"%
        }
        \setlength{\th@mbheighty}{\z@}%
        \addtolength{\th@mbheighty}{\@tempdima}% = \thumbs@minheight
     \fi%
    \else%
%    \end{macrocode}
%
% When a value has been given for the thumb marks' height, this fixed value is used.
%
%    \begin{macrocode}
      \ifthumbs@verbose%
        \edef\thumbsinfo{\the\th@mbheighty}%
        \PackageInfo{thumbs}{Now setting thumbs' height to \thumbsinfo}%
      \fi%
      \setlength{\th@mbheighty}{\thumbs@height}%
    \fi%
  \fi%
%    \end{macrocode}
%
% Read in the |\jobname.tmb|-file:
%
%    \begin{macrocode}
  \newread\@instreamthumb%
%    \end{macrocode}
%
% Inform the users about the dimensions of the thumb marks (look in the \xfile{log} file):
%
%    \begin{macrocode}
  \ifthumbs@verbose%
    \message{^^J}%
    \edef\thumbsinfo{\the\th@mbheighty}%
    \PackageInfo{thumbs}{************** THUMB dimensions **************\@gobbletwo}%
    \PackageInfo{thumbs}{The height of the thumb marks is \thumbsinfo\@gobble}%
  \fi%
%    \end{macrocode}
%
% Setting the thumb mark width (|\th@mbwidthx|):
%
%    \begin{macrocode}
  \ifthumbs@draft%
    \setlength{\th@mbwidthx}{2pt}%
  \else%
    \setlength{\th@mbwidthx}{\paperwidth}%
    \addtolength{\th@mbwidthx}{-\textwidth}%
    \divide\th@mbwidthx by 4%
    \setlength{\@tempdima}{0sp}%
    \ifx\thumbs@width\empty%
    \else%
      \def\th@mbstest{auto}%
      \ifx\thumbs@width\th@mbstest%
      \else%
        \def\th@mbstest{autoauto}%
        \ifx\thumbs@width\th@mbstest%
          \@ifundefined{th@mbmaxwidtha}{%
            \if@filesw%
              \gdef\th@mbmaxwidtha{0sp}%
              \setlength{\th@mbwidthx}{\th@mbmaxwidtha}%
              \AddToHook{enddocument/info}[kernel/warnings]{%
                \PackageWarningNoLine{thumbs}{%
                  \string\th@mbmaxwidtha\space undefined.\MessageBreak%
                  Rerun to get the thumb marks width right%
                 }%
              }%
            \else%
              \PackageError{thumbs}{You cannot use option autoauto without \jobname.aux file}{%
                Recompilation should create the .aux file,\MessageBreak%
                otherwise do not use the autoauto option.}%
            \fi%
          }{%\else
            \setlength{\th@mbwidthx}{\th@mbmaxwidtha}%
          }%\fi
        \else%
          \ifdim \thumbs@width > \@tempdima% OK
            \setlength{\th@mbwidthx}{\thumbs@width}%
          \else%
            \PackageError{thumbs}{Thumbs not wide enough}{%
              Option width has value "\thumbs@width".\MessageBreak%
              This is not a valid dimension larger than zero.\MessageBreak%
              Width will be set automatically.}%
          \fi%
        \fi%
      \fi%
    \fi%
  \fi%
  \ifthumbs@verbose%
    \edef\thumbsinfo{\the\th@mbwidthx}%
    \PackageInfo{thumbs}{The width of the thumb marks on the paper is \thumbsinfo\@gobble}%
    \ifthumbs@draft%
      \PackageInfo{thumbs}{because thumbs package is in draft mode\@gobble}%
    \fi%
  \fi%
%    \end{macrocode}
%
% Setting the position of the first/top thumb mark. Vertical (y) position
% is a little bit complicated, because option\newline
% |\thumbs@topthumbmargin| must be handled:
%
%    \begin{macrocode}
  % Thumb position x \th@mbposx
  \setlength{\th@mbposx}{\paperwidth}%
  \addtolength{\th@mbposx}{-\th@mbwidthx}%
  \ifthumbs@ignorehoffset%
    \addtolength{\th@mbposx}{-\hoffset}%
  \fi%
  \addtolength{\th@mbposx}{1pt}%
  % Thumb position y \th@mbposy
  \ifx\thumbs@topthumbmargin\empty%
    \def\thumbs@topthumbmargin{auto}%
  \fi%
%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
  \def\th@mbstest{auto}%
  \ifx\thumbs@topthumbmargin\th@mbstest%
    \setlength{\th@mbposy}{1in}%
    \addtolength{\th@mbposy}{+\topmargin}%
    \addtolength{\th@mbposy}{-\th@mbsdistance}%
    \addtolength{\th@mbposy}{+\th@mbheighty}%
  \else%
    \setlength{\@tempdima}{-1pt}%
    \ifdim\thumbs@topthumbmargin > \@tempdima\relax%
    \else%
      \PackageWarning{thumbs}{Thumbs column starting too high.\MessageBreak%
        Option topthumbmargin has value "\thumbs@topthumbmargin ".\MessageBreak%
        topthumbmargin will be set to -1pt.\MessageBreak%
       }%
      \gdef\thumbs@topthumbmargin{-1pt}%
    \fi%
    \setlength{\th@mbposy}{\thumbs@topthumbmargin}%
    \addtolength{\th@mbposy}{-\th@mbsdistance}%
    \addtolength{\th@mbposy}{+\th@mbheighty}%
  \fi%
  \setlength{\th@mbposytop}{\th@mbposy}%
  \ifthumbs@verbose%
    \setlength{\@tempdimc}{\th@mbposytop}%
    \addtolength{\@tempdimc}{-\th@mbheighty}%
    \addtolength{\@tempdimc}{+\th@mbsdistance}%
    \edef\thumbsinfo{\the\@tempdimc}%
    \PackageInfo{thumbs}{The top thumb margin is \thumbsinfo\@gobble}%
  \fi%
%    \end{macrocode}
%
% Setting the lowest position of a thumb mark, according to option |\thumbs@bottomthumbmargin|:
%
%    \begin{macrocode}
  % Max. thumb position y \th@mbposybottom
  \ifx\thumbs@bottomthumbmargin\empty%
    \gdef\thumbs@bottomthumbmargin{auto}%
  \fi%
  \def\th@mbstest{auto}%
  \ifx\thumbs@bottomthumbmargin\th@mbstest%
    \setlength{\th@mbposybottom}{1in}%
    \addtolength{\th@mbposybottom}{+\th@bmsvoffset}%
    \addtolength{\th@mbposybottom}{+\topmargin}%
    \addtolength{\th@mbposybottom}{-\th@mbsdistance}%
    \addtolength{\th@mbposybottom}{+\th@mbheighty}%
    \addtolength{\th@mbposybottom}{+\headheight}%
    \addtolength{\th@mbposybottom}{+\headsep}%
    \addtolength{\th@mbposybottom}{+\textheight}%
    \addtolength{\th@mbposybottom}{+\footskip}%
    \addtolength{\th@mbposybottom}{-\th@mbsdistance}%
    \addtolength{\th@mbposybottom}{-\th@mbheighty}%
    \IfPackageLoadedT{crop}{\addtolength{\th@mbposybottom}{-\th@bmsvoffset}}%
  \else%
    \setlength{\@tempdima}{\paperheight}%
    \addtolength{\@tempdima}{-\thumbs@bottomthumbmargin}%
    \addtolength{\@tempdima}{-\th@mbposytop}%
    \addtolength{\@tempdima}{-\th@mbsdistance}%
    \addtolength{\@tempdima}{-\th@mbheighty}%
    \addtolength{\@tempdima}{-\th@mbsdistance}%
    \IfPackageLoadedT{crop}{\addtolength{\@tempdima}{-\th@bmsvoffset}}%
    \ifdim \@tempdima > 0sp\relax%
    \else%
      \setlength{\@tempdima}{\paperheight}%
      \addtolength{\@tempdima}{-\th@mbposytop}%
      \addtolength{\@tempdima}{-\th@mbsdistance}%
      \addtolength{\@tempdima}{-\th@mbheighty}%
      \addtolength{\@tempdima}{-\th@mbsdistance}%
      \addtolength{\@tempdima}{-1pt}%
      \IfPackageLoadedT{crop}{\addtolength{\@tempdima}{-\th@bmsvoffset}}%
      \PackageWarning{thumbs}{Thumbs column ending too high.\MessageBreak%
        Option bottomthumbmargin has value "\thumbs@bottomthumbmargin ".\MessageBreak%
        bottomthumbmargin will be set to "\the\@tempdima".\MessageBreak%
       }%
      \xdef\thumbs@bottomthumbmargin{\the\@tempdima}%
    \fi%
    \setlength{\@tempdima}{\thumbs@bottomthumbmargin}%
    \setlength{\@tempdimc}{-1pt}%
    \ifdim \@tempdima < \@tempdimc%
      \PackageWarning{thumbs}{Thumbs column ending too low.\MessageBreak%
        Option bottomthumbmargin has value "\thumbs@bottomthumbmargin ".\MessageBreak%
        bottomthumbmargin will be set to -1pt.\MessageBreak%
       }%
      \gdef\thumbs@bottomthumbmargin{-1pt}%
    \fi%
    \setlength{\th@mbposybottom}{\paperheight}%
    \addtolength{\th@mbposybottom}{-\thumbs@bottomthumbmargin}%
  \fi%
  \ifthumbs@verbose%
    \setlength{\@tempdimc}{\paperheight}%
    \addtolength{\@tempdimc}{-\th@mbposybottom}%
    \edef\thumbsinfo{\the\@tempdimc}%
    \PackageInfo{thumbs}{The bottom thumb margin is \thumbsinfo\@gobble}%
    \PackageInfo{thumbs}{**********************************************\@gobbletwo}%
    \message{^^J}%
  \fi%
%    \end{macrocode}
%
% \pagebreak
% |\th@mbposyA| is set to the top-most vertical thumb position~(y).
% Because it will be increased \hbox{(i.\,e. the} thumb positions will move downwards
% on the page), |\th@mbsposytocyy| is used to remember this position unchanged.
%
%    \begin{macrocode}
  \addtolength{\th@mbposy}{-\th@mbheighty}% because it will be advanced also for the first thumb.
  \setlength{\th@mbposyA}{\th@mbposy}%      \th@mbposyA will change.
  \setlength{\th@mbsposytocyy}{\th@mbposy}% \th@mbsposytocyy shall not be changed.
  }

%    \end{macrocode}
%
%    \begin{macro}{\th@mb@dvance}
% The internal command |\th@mb@dvance| is used to advance the position of the current
% thumb by |\th@mbheighty| and |\th@mbsdistance|. If the resulting position
% of the thumb is lower than the |\th@mbposybottom| position \hbox{(i.\,e.~|\th@mbposy|}
% \emph{higher} than |\th@mbposybottom|), a~new thumb column will be started by the next
% |\addthumb|, otherwise a blank thumb is created and |\th@mb@dvance| is calling itself
% again. This loop continues until a new thumb column is ready to be started.
%
%    \begin{macrocode}
\newcommand{\th@mb@dvance}{%
  \addtolength{\th@mbposy}{+\th@mbheighty}%
  \addtolength{\th@mbposy}{+\th@mbsdistance}%
  \ifdim\th@mbposy>\th@mbposybottom\relax%
    \addtolength{\th@mbposy}{-\th@mbheighty}%
    \addtolength{\th@mbposy}{-\th@mbsdistance}%
  \else%
    \addtolength{\th@mbposy}{-\th@mbheighty}%
    \addtolength{\th@mbposy}{-\th@mbsdistance}%
    \thumborigaddthumb{}{}{\string\thepagecolor}{\string\thepagecolor}%
    \th@mb@dvance%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\thumbnewcolumn}
% With the command |\thumbnewcolumn| a new column can be started, even if the current one
% was not filled. This could be useful e.\,g.~for a dictionary, which uses one column for
% translations from language~A to language~B, and the second column for translations
% from language~B to language~A. But in that case one probably should increase the
% size of the thumb marks, so that $26$~thumb marks (in~case of the Latin alphabet)
% fill one thumb column. Do not use |\thumbnewcolumn| on a page where |\addthumb| was
% already used, but use |\addthumb| immediately after |\thumbnewcolumn|.
%
%    \begin{macrocode}
\newcommand{\thumbnewcolumn}{%
  \ifx\th@mbtoprint\thumbs@one\relax%
    \PackageError{thumbs}{\string\thumbnewcolumn\space after \string\addthumb }{%
      On page \thepage\space (approx.) \string\addthumb\space was used and *afterwards* %
      \string\thumbnewcolumn .\MessageBreak%
      When you want to use \string\thumbnewcolumn , do not use an \string\addthumb\space %
      on the same\MessageBreak%
      page before \string\thumbnewcolumn . Thus, either remove the \string\addthumb , %
      or use a\MessageBreak%
      \string\pagebreak , \string\newpage\space etc. before \string\thumbnewcolumn .\MessageBreak%
      (And remember to use an \string\addthumb\space*after* \string\thumbnewcolumn .)\MessageBreak%
      Your command \string\thumbnewcolumn\space will be ignored now.%
      }%
  \else%
    \PackageWarning{thumbs}{%
      Starting of another column requested by command\MessageBreak%
      \string\thumbnewcolumn.\space Only use this command directly\MessageBreak%
      before an \string\addthumb\space - did you?!\MessageBreak%
      Code}%
    \gdef\th@mbcolumnnew{1}%
    \th@mb@dvance%
    \gdef\th@mbprinting{0}%
    \gdef\th@mbcolumnnew{2}%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\addtitlethumb}
% When a thumb mark shall not or cannot be placed on a page, e.\,g.~at the title page or
% when using |\includepdf| from \xpackage{pdfpages} package, but the reference in the thumb
% marks overview nevertheless shall name that page number and hyperlink to that page,
% |\addtitlethumb| can be used at the following page. It has five arguments. The arguments
% one to four are identical to the ones of |\addthumb| (see below),
% and the fifth argument consists of the label of the page, where the hyperlink
% at the thumb marks overview page shall link to.
% If manually no label can be placed on the first page, the label \texttt{pagesLTS.0}
% from the \xpackage{pageslts} package (needs to be loaded explicitly!) can be used.
%
%    \begin{macrocode}
\newcommand{\addtitlethumb}[5]{%
  \xdef\th@mb@titlelabel{#5}%
  \addthumb{#1}{#2}{#3}{#4}%
  \xdef\th@mb@titlelabel{}%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\thumbsnophantom}
% To locally disable the setting of a |\phantomsection| before a thumb mark,
% the command |\thumbsnophantom| is provided. (But at first it is not disabled.)
%
%    \begin{macrocode}
\gdef\th@mbsphantom{1}

\newcommand{\thumbsnophantom}{\gdef\th@mbsphantom{0}}

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\addthumb}
% Now the |\addthumb| command is defined, which is used to add a new
% thumb mark to the document. |\th@mbs@fr@meinnercolor| was
% |\thepagecolor| instead of |\thumbs@frameinnercolor|,
% if no thumb mark was issued.
%
%    \begin{macrocode}
\newcommand{\addthumb}[4]{%
  \gdef\th@mbs@fr@meinnercolor{\thumbs@frameinnercolor}%
  \gdef\th@mbprinting{1}%
  \addtolength{\th@mbposy}{\th@mbheighty}%
  \addtolength{\th@mbposy}{\th@mbsdistance}%
  \ifdim\th@mbposy>\th@mbposybottom%
    \PackageInfo{thumbs}{Thumbs column full, starting another column\MessageBreak}%
    \setlength{\th@mbposy}{\th@mbposytop}%
    \addtolength{\th@mbposy}{\th@mbsdistance}%
%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
    \ifx\th@mbcolumn\thumbs@zero\relax%
      \xdef\th@umbsperpagecount{\th@mbs}%
      \gdef\th@mbcolumn{1}%
    \fi%
  \fi%
  \setcounter{Th@mbTmpA}{\th@mbs}%
  \addtocounter{Th@mbTmpA}{1}%
  \xdef\th@mbs{\the\c@Th@mbTmpA}%
%    \end{macrocode}
%
% The |\addthumb| command has four parameters:
% \begin{enumerate}
% \item a title for the thumb mark (for the thumb marks overview page, e.\,g.~the chapter title),
%
% \item the text to be displayed in the thumb mark (for example a chapter number),
%
% \item the colour of the text in the thumb mark,
%
% \item and the background colour of the thumb mark
% \end{enumerate}
% (parameters in this order).
%
%    \begin{macrocode}
  \gdef\th@mbtitle{#1}%
  \gdef\th@mbtext{#2}%
  \gdef\th@mbtextcolour{#3}%
  \gdef\th@mbbackgroundcolour{#4}%
%    \end{macrocode}
%
% \phantomsection\label{tmtww}
% The width of the thumb mark text is determined and compared to the width of the
% thumb mark (rule). When the text is wider than the rule, this has to be changed
% (either automatically with option |width={autoauto}| in the next compilation run
% or manually by changing |width={|\ldots|}| by the user). It could be acceptable
% to have a thumb mark text consisting of more than one line, of course, in which
% case nothing needs to be changed. Possible horizontal movement (|\th@mbHitO|,
% |\th@mbHitE|) has to be taken into account.
%
%    \begin{macrocode}
  \settowidth{\@tempdima}{\th@mbtext}%
  \ifdim\th@mbHitO>\th@mbHitE\relax%
    \addtolength{\@tempdima}{\th@mbHitO}%
  \else%
    \addtolength{\@tempdima}{\th@mbHitE}%
  \fi%
  \ifdim\@tempdima>\th@mbmaxwidth%
    \xdef\th@mbmaxwidth{\the\@tempdima}%
  \fi%
  \ifdim\@tempdima>\th@mbwidthx%
    \ifthumbs@draft% \relax
    \else%
      \edef\thumbsinfoa{\the\th@mbwidthx}
      \edef\thumbsinfob{\the\@tempdima}
      \PackageWarning{thumbs}{%
        Thumb mark on paper too small (width: \thumbsinfoa )\MessageBreak%
        or its text too wide (width:%
        \space\space\space\space\space\space\space\space\space\space%
        \thumbsinfob )\MessageBreak%
       }%
    \fi%
  \fi%
%    \end{macrocode}
%
% Into the |\jobname.tmb| file a |\thumbcontents| entry is written.
% If \xpackage{hyperref} is found, a |\phantomsection| is placed (except when
% globally disabled by option |nophantomsection| or locally by |\thumbsnophantom|),
% a~label for the thumb mark created, and the |\thumbcontents| entry will be
% hyperlinked to that label (except when |\addtitlethumb| was used, then the label
% reported from the user is used -- the \xpackage{thumbs} package does \emph{not}
% create that label!).
%
%    \begin{macrocode}
  \IfPackageLoadedT{hyperref}{%
    \ifthumbs@nophantomsection%
    \else%
      \ifx\th@mbsphantom\thumbs@one\relax%
        \phantomsection%
      \else%
        \gdef\th@mbsphantom{1}%
      \fi%
    \fi%
  }%
  \label{thumbs.\th@mbs}%
  \if@filesw%
    \ifx\th@mb@titlelabel\empty%
      \addtocontents{tmb}{\string\thumbcontents{#1}{#2}{#3}{#4}{\thepage}{thumbs.\th@mbs}{\th@mbcolumnnew}\protected@file@percent}%
    \else%
      \addtocounter{page}{-1}%
      \edef\th@mb@page{\thepage}%
      \addtocontents{tmb}{\string\thumbcontents{#1}{#2}{#3}{#4}{\th@mb@page}{\th@mb@titlelabel}{\th@mbcolumnnew}\protected@file@percent}%
      \addtocounter{page}{+1}%
    \fi%
 %\else there is a problem, but the according warning message was already given earlier.
  \fi%
%    \end{macrocode}
%
% Maybe there is a rare case, where more than one thumb mark will be placed at one page.
% Probably a |\pagebreak|, |\newpage| or something similar would be advisable,
% but nevertheless we should prepare for this case. We save the properties of the thumb mark(s).
%
%    \begin{macrocode}
  \ifx\th@mbcolumnnew\thumbs@one\relax%
  \else%
    \setcounter{Th@mbTmpA}{\th@mbonpage}%
    \addtocounter{Th@mbTmpA}{1}%
    \xdef\th@mbonpage{\the\c@Th@mbTmpA}%
  \fi%
  \ifx\th@mbtoprint\thumbs@zero\relax%
  \else%
    \ifx\th@mbcolumnnew\thumbs@zero\relax%
      \PackageWarning{thumbs}{More than 1 thumb at 1 page:\MessageBreak%
        You placed more than 1 thumb mark (at least \th@mbonpage )\MessageBreak%
        on page \thepage\space (page is approximately).\MessageBreak%
        Maybe you want to insert a page break here?\MessageBreak%
        Thumb added}%
    \fi%
  \fi%
  \ifnum\th@mbonpage=1%
    \ifnum\th@mbonpagemax>0% \relax
    \else \gdef\th@mbonpagemax{1}%
    \fi%
    \gdef\th@mbtextA{#2}%
    \gdef\th@mbtextcolourA{#3}%
    \gdef\th@mbbackgroundcolourA{#4}%
    \setlength{\th@mbposyA}{\th@mbposy}%
  \else%
    \ifx\th@mbcolumnnew\thumbs@zero\relax%
      \setcounter{Th@mbTmpA}{\the\c@Th@mbTmpA}%
      \@tempcnta=1\relax%
      \edef\th@mbonpagetest{\the\@tempcnta}%
      \@whilenum\th@mbonpagetest<\th@mbonpage\do{%
       \advance\@tempcnta by 1%
       \xdef\th@mbonpagetest{\the\@tempcnta}%
       \ifnum\th@mbonpage=\th@mbonpagetest%
         \ifnum\th@mbonpagemax<\th@mbonpage%
           \xdef\th@mbonpagemax{\th@mbonpage}%
         \fi%
         \edef\th@mbtmpdef{\csname th@mbtext\AlphAlph{\the\@tempcnta}\endcsname}%
         \expandafter\gdef\th@mbtmpdef{#2}%
         \edef\th@mbtmpdef{\csname th@mbtextcolour\AlphAlph{\the\@tempcnta}\endcsname}%
         \expandafter\gdef\th@mbtmpdef{#3}%
         \edef\th@mbtmpdef{\csname th@mbbackgroundcolour\AlphAlph{\the\@tempcnta}\endcsname}%
         \expandafter\gdef\th@mbtmpdef{#4}%
       \fi%
      }%
      \@tempcnta=\the\c@Th@mbTmpA\relax%
    \else%
      \ifnum\th@mbonpagemax<\th@mbonpage%
        \xdef\th@mbonpagemax{\th@mbonpage}%
      \fi%
    \fi%
  \fi%
  \ifx\th@mbcolumnnew\thumbs@two\relax%
    \gdef\th@mbcolumnnew{0}%
  \fi%
  \gdef\th@mbtoprint{1}%
  }

%    \end{macrocode}
%    \end{macro}
%
% \pagebreak
%    \begin{macro}{\stopthumb}
% When a page (or pages) shall have no thumb marks, |\stopthumb| stops the issuing%
% of thumb marks (until another thumb mark is placed or |\continuethumb| is used).
%
%    \begin{macrocode}
\newcommand{\stopthumb}{\gdef\th@mbprinting{0}}

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\continuethumb}
% |\continuethumb| continues the issuing of thumb marks (equal to the one
% before this was stopped by |\stopthumb|).
%
%    \begin{macrocode}
\newcommand{\continuethumb}{\gdef\th@mbprinting{1}}

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\th@mbtabrule}
% |\th@mbtabrule| prints the background rules in the thumb mark index page.
% If frames instead of filled marks are used, a second (smaller) rule in colour %
% |\thumbs@frameinnercolor| needs to be printed over the first rule.
%
%    \begin{macrocode}
\newcommand{\th@mbtabrule}{%
  \rule{\dimexpr\th@mbwidthxtoc+\th@mbruleoutside\relax}{\th@mbheighty}%
  \ifx\thumbs@frame\thumbs@empty\relax%
  \else%
    \hspace*{-\th@mbwidthxtoc}%
    \hspace*{\thumbs@frame}%
    \setlength{\th@mbwidthtmp}{\th@mbwidthxtoc}%
    \addtolength{\th@mbwidthtmp}{-\thumbs@frame}%
    \addtolength{\th@mbwidthtmp}{-\thumbs@frame}%
    \xdef\th@mbfrw{\the\th@mbwidthtmp}%
    \setlength{\th@mbwidthtmp}{\th@mbheighty}%
    \addtolength{\th@mbwidthtmp}{-\thumbs@frame}%
    \addtolength{\th@mbwidthtmp}{-\thumbs@frame}%
    {\color{\thumbs@frameinnercolor}%
     \rule[\thumbs@frame]{\th@mbfrw}{\th@mbwidthtmp}%
    }%
    \hspace*{\thumbs@frame}%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{environment}{thumbspicture}
%
% This package uses |picture| environments to place some stuff. When tagging is a thing,
% pictures need alt-text, thus there would be a warning of missing alt-text.
% Alternatively |artifact| for decorations and |actualtext| for symbols could be used.
% But if such option for the |picture| environment would be used without |\DocumentMetadata|,
% then an error would result because in that case there is no such option for the
% |picture| environment. Thus we need to define a wrapper environment |thumbspicture|:
%
%    \begin{macrocode}
\newenvironment{thumbspicture}[1][]{\gdef\thumbs@picture@option{#1}\thumbs@picture@parse}{\end{picture}}

\def\thumbs@picture@parse(#1){%
  \IfDocumentMetadataTF{\expanded{\noexpand\begin{picture}[\thumbs@picture@option]}(#1)%
  }{\begin{picture}(#1)}%
}

%    \end{macrocode}
%    \end{environment}
%
%    \begin{macro}{\thumbcontents}
% The \textbf{internal} command |\thumbcontents| (which will be read in from the
% |\jobname.tmb| file) creates a thumb mark entry on the overview page(s).
% Its seven parameters are
% \begin{enumerate}
% \item the title for the thumb mark,
%
% \item the text to be displayed in the thumb mark,
%
% \item the colour of the text in the thumb mark,
%
% \item the background colour of the thumb mark,
%
% \item the first page of this thumb mark,
%
% \item the label where it should hyperlink to,
%
% \item and an indicator, whether |\thumbnewcolumn| is just issuing blank thumbs to fill a column
% \end{enumerate}
% (parameters in this order). Without \xpackage{hyperref} the
% $6\textsuperscript{th}$~parameter is just ignored.
%
%    \begin{macrocode}
\newcommand{\thumbcontents}[7]{%
  \addtolength{\th@mbposy}{\th@mbheighty}%
  \addtolength{\th@mbposy}{\th@mbsdistance}%
  \ifdim\th@mbposy>\th@mbposybottom%
    \setlength{\th@mbposy}{\th@mbposytop}%
    \addtolength{\th@mbposy}{\th@mbsdistance}%
  \fi%
  \def\th@mb@tmp@title{#1}%
  \def\th@mb@tmp@text{#2}%
  \def\th@mb@tmp@textcolour{#3}%
  \def\th@mb@tmp@backgroundcolour{#4}%
  \def\th@mb@tmp@page{#5}%
  \def\th@mb@tmp@label{#6}%
  \def\th@mb@tmp@column{#7}%
  \ifx\th@mb@tmp@column\thumbs@two\relax%
    \def\th@mb@tmp@column{0}%
  \fi%
  \setlength{\th@mbwidthxtoc}{\paperwidth}%
  \addtolength{\th@mbwidthxtoc}{-1in}%
%    \end{macrocode}
%
% Depending on which side the thumb marks should be placed the according dimensions have to be adapted.
%
%    \begin{macrocode}
  \def\th@mbstest{r}%
  \ifx\th@mbstest\th@mbsprintpage% right page
    \addtolength{\th@mbwidthxtoc}{-\th@mbHimO}%
    \addtolength{\th@mbwidthxtoc}{-\oddsidemargin}%
    \setlength{\@tempdimc}{1in}%
    \addtolength{\@tempdimc}{+\oddsidemargin}%
%    \end{macrocode}
% \pagebreak
%    \begin{macrocode}
  \else% left page
    \addtolength{\th@mbwidthxtoc}{-\th@mbHimE}%
    \addtolength{\th@mbwidthxtoc}{-\evensidemargin}%
    \setlength{\@tempdimc}{\th@bmshoffset}%
    \addtolength{\@tempdimc}{-\hoffset}
  \fi%
  \setlength{\th@mbposyB}{-\th@mbposy}%
  \if@twoside%
    \setcounter{Th@mbTmpA}{\the\c@ThumbsPage}%
    \addtocounter{Th@mbTmpA}{\th@mbpofffix}%
    \ifodd\c@Th@mbTmpA\relax%
    \else%
      \addtolength{\th@mbposyB}{-\thumbs@evenprintvoffset}%
    \fi%
  \fi%
  \def\th@mbstest{l}%
  \ifx\th@mbstest\th@mbsprintpage% left page
    \addtolength{\@tempdimc}{+\th@mbHimE}%
%    \end{macrocode}
%
% Thumb rules on right pages shall start $1\unit{em}$ before the text:
%
%    \begin{macrocode}
    \setlength{\@tempdimb}{0em}%
  \else% right page
    \setlength{\@tempdimb}{1em}%
  \fi%
  \addtolength{\@tempdimc}{-\@tempdimb}%
  \addtolength{\th@mbwidthxtoc}{\@tempdimb}%
  \put(\@tempdimc,\th@mbposyB){%
    \ifx\th@mbstest\th@mbsprintpage% left page
%    \end{macrocode}
%
% Increase |\th@mbwidthxtoc| by the absolute value of |\evensidemargin|.\newline
% With the \xpackage{bigintcalc} package it would also be possible to use:\newline
% |\setlength{\@tempdimb}{\evensidemargin}%|\newline
% |\@settopoint\@tempdimb%|\newline
% |\advance\th@mbwidthxtoc+\bigintcalcSgn{\expandafter\strip@pt \@tempdimb}\evensidemargin%|\newline
% Also the length given by option |leftindexruleplus| must be added to the thumb width
% |\th@mbwidthxtoc|. - For right-to-left writing |2\evensidemargin|s need to be added.
%
%    \begin{macrocode}
      \ifdim\evensidemargin <0sp\relax%
        \addtolength{\th@mbwidthxtoc}{-\evensidemargin}%
        \ifthumbs@righttoleft\addtolength{\th@mbwidthxtoc}{-\evensidemargin}\fi%
      \else% >=0sp
        \addtolength{\th@mbwidthxtoc}{+\evensidemargin}%
        \ifthumbs@righttoleft\addtolength{\th@mbwidthxtoc}{+\evensidemargin}\fi%
      \fi%
      \addtolength{\th@mbwidthxtoc}{\th@mbslirplus}%
    \fi%
    \begin{thumbspicture}[artifact](\@tempdimb,0)%
%    \end{macrocode}
%
% Correcting for |\th@mbruleoutside| (only needed on left sides).
%
%    \begin{macrocode}
      \ifx\th@mbstest\th@mbsprintpage% left page
        \def\th@mbruleoutsidecor{\th@mbruleoutside}%
        \hspace*{-\th@mbruleoutsidecor}%
      \else% right page
        \def\th@mbruleoutsidecor{0sp}%
%    \end{macrocode}
% Here also |\hspace*{-\th@mbruleoutsidecor}|, but |\th@mbruleoutsidecor| is |0sp|, so we can skip this.
%    \begin{macrocode}
      \fi%
%    \end{macrocode}
%
% The whole entry in the overview page (edge index) is made into a coloured rule.
% When the option |plainthumbsoverview=true| is chosen, the rule gets |\thepagecolor|,
% thereby becoming \textquotedblleft invisible\textquotedblright .
%
%    \begin{macrocode}
      \ifthumbs@plainthumbsoverview\relax%
        \def\th@mb@tmp@backgroundcolour{\thepagecolor}%
      \fi%
%    \end{macrocode}
%
% When the option |thumblink=rule| was chosen, the whole rule is made into a hyperlink.
% Otherwise the rule is created without hyperlink (here).
%
%    \begin{macrocode}
      \def\th@mbstest{rule}%
      \ifx\thumbs@thumblink\th@mbstest%
        \ifx\th@mb@tmp@column\thumbs@zero\relax%
         {\color{\th@mb@tmp@backgroundcolour}%
%    \end{macrocode}
%
% Print the |\rule|, on left pages move the hyperlink to the right, onto the page,
% make the hyperlink.
%
%    \begin{macrocode}
          \rlap{\th@mbtabrule}%
          \hspace*{\th@mbruleoutsidecor}%
          \hyperref[\th@mb@tmp@label]{\phantom{\rule{\th@mbwidthxtoc}{\th@mbheighty}}}%
         }%
        \else%
%    \end{macrocode}
%
% When |\th@mb@tmp@column| is not zero, then this is a blank thumb mark from |thumbnewcolumn|.
%
%    \begin{macrocode}
          \phantom{{\color{\th@mb@tmp@backgroundcolour}\th@mbtabrule}}%
        \fi%
      \else%
        {\color{\th@mb@tmp@backgroundcolour}\th@mbtabrule}%
      \fi%
    \end{thumbspicture}%
%    \end{macrocode}
%
% When |\th@mbsprintpage| is |l|, before the picture |\th@mbwidthxtoc| was changed,
% which must be reverted now.
%
%    \begin{macrocode}
    \ifx\th@mbstest\th@mbsprintpage% l
      \ifdim\evensidemargin <0sp\relax%
        \addtolength{\th@mbwidthxtoc}{+\evensidemargin}%
      \else% >=0sp
        \addtolength{\th@mbwidthxtoc}{-\evensidemargin}%
      \fi%
    \fi%
%    \end{macrocode}
%
% When |\th@mb@tmp@column| is zero, then this is \textbf{not} a blank thumb mark from |thumbnewcolumn|,
% and we need to fill it with some content. If it is not zero, it is a blank thumb mark,
% and nothing needs to be done here.
%
%    \begin{macrocode}
    \ifx\th@mb@tmp@column\thumbs@zero\relax%
      \setlength{\th@mbwidthxtoc}{\paperwidth}%
      \addtolength{\th@mbwidthxtoc}{-1in}%
      \IfPackageLoadedF{crop}{\addtolength{\th@mbwidthxtoc}{-\hoffset}}%
      \ifx\th@mbstest\th@mbsprintpage% l
        \addtolength{\th@mbwidthxtoc}{-\evensidemargin}%
      \else%
        \addtolength{\th@mbwidthxtoc}{-\oddsidemargin}%
      \fi%
%    \end{macrocode}
%
% When the text is wider than its mark (warning given earlier, see \pageref{tmtww}),
% we need to use the text width instead of the mark width.
%
%    \begin{macrocode}
      \setlength{\@tempdima}{\th@mbwidthx}%
      \setlength{\@tempdimc}{\th@mbmaxwidtha}%
      \ifdim\@tempdima>\@tempdimc\relax%
        \addtolength{\th@mbwidthxtoc}{-\th@mbwidthx}%
      \else%
        \addtolength{\th@mbwidthxtoc}{-\th@mbmaxwidtha}%
      \fi%
      \addtolength{\th@mbwidthxtoc}{-1em}%
      \addtolength{\th@mbwidthxtoc}{-20pt}%
      \ifdim\th@mbwidthxtoc>\textwidth%
        \setlength{\th@mbwidthxtoc}{\textwidth}%
      \fi%
%    \end{macrocode}
%
% If option |plainthumbsoverview| was set, the coloured background must be removed.
% (Well, removing is not possible, but printing over it in |\thepagecolour|.)
%
%    \begin{macrocode}
      \ifx\th@mbstest\th@mbsprintpage% left page
        \ifthumbs@plainthumbsoverview\relax%
          \begin{thumbspicture}[artifact](0,0)%
            {\color{\th@mb@tmp@backgroundcolour}\rule{\th@mbwidthx}{\th@mbheighty}}%
          \end{thumbspicture}%
        \fi%
%    \end{macrocode}
%
% Depending on which side the thumb marks should be placed the
% according dimensions have to be adapted here, too.
%
%    \begin{macrocode}
        \begin{thumbspicture}[artifact](-\th@mbHimE,0)(-6pt,-0.5\th@mbheighty+384930sp)%
          \bgroup%
            \setlength{\parindent}{0sp}%
            \setlength{\@tempdimc}{\th@mbwidthx}%
            \addtolength{\@tempdimc}{-\th@mbHitO}%
            \setlength{\@tempdimb}{\th@mbwidthx}%
            \addtolength{\@tempdimb}{-\th@mbHitE}%
            \setcounter{Th@mbTmpA}{\c@ThumbsPage}%
            \addtocounter{Th@mbTmpA}{\th@mbpofffix}%
%    \end{macrocode}
% \newpage
%    \begin{macrocode}
            \ifodd\c@Th@mbTmpA\relax%
              \hspace*{-\th@mbHitO}%
              \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
            \else%
              \if@twoside%
                \hspace*{+\th@mbHitE}%
                \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{l}{\@tempdimb}%
              \else%
                \hspace*{-\th@mbHitO}%
                \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
              \fi%
            \fi%
          \egroup%
        \end{thumbspicture}%
        \setlength{\@tempdimc}{-1in}%
        \addtolength{\@tempdimc}{-\evensidemargin}%
      \else% right page
        \setlength{\@tempdimc}{0sp}%
      \fi%
      \begin{thumbspicture}[artifact](0,0)(\@tempdimc,-0.5\th@mbheighty+384930sp)%
        \bgroup%
%    \end{macrocode}
%
% With option |plainthumbsoverview| |\th@mb@tmp@textcolour| must be defined (current colour).
%
%    \begin{macrocode}
          \ifthumbs@plainthumbsoverview\relax%
            \def\th@mb@tmp@textcolour{.}%
          \fi%
          \setlength{\parindent}{0sp}%
          \vbox%
           {\hsize=\th@mbwidthxtoc {%
%    \end{macrocode}
%
% Depending on the value of option |thumblink|, parts of the text are made into hyperlinks:
% \begin{description}
% \item[- |none|] creates \emph{none} hyperlink
%
%    \begin{macrocode}
              \def\th@mbstest{none}%
              \ifx\thumbs@thumblink\th@mbstest%
                {\color{\th@mb@tmp@textcolour}\noindent \th@mb@tmp@title%
                 \leaders\box \ThumbsBox {\th@mbs@linefill \th@mb@tmp@page}%
                }%
              \else%
%    \end{macrocode}
%
% \item[- |title|] hyperlinks the \emph{titles} of the thumb marks
%
%    \begin{macrocode}
                \def\th@mbstest{title}%
                \ifx\thumbs@thumblink\th@mbstest%
                  {\color{\th@mb@tmp@textcolour}\noindent%
                   \hyperref[\th@mb@tmp@label]{\th@mb@tmp@title}%
                   \leaders\box \ThumbsBox {\th@mbs@linefill \th@mb@tmp@page}%
                  }%
                \else%
%    \end{macrocode}
%
% \item[- |page|] hyperlinks the \emph{page} numbers of the thumb marks
%
%    \begin{macrocode}
                  \def\th@mbstest{page}%
                  \ifx\thumbs@thumblink\th@mbstest%
                    {\color{\th@mb@tmp@textcolour}\noindent%
                     \th@mb@tmp@title%
                     \leaders\box \ThumbsBox {\th@mbs@linefill \pageref{\th@mb@tmp@label}}%
                    }%
                  \else%
%    \end{macrocode}
%
% \item[- |titleandpage|] hyperlinks the \emph{title and page} numbers of the thumb marks
%
%    \begin{macrocode}
                    \def\th@mbstest{titleandpage}%
                    \ifx\thumbs@thumblink\th@mbstest%
                      {\color{\th@mb@tmp@textcolour}\noindent%
                       \hyperref[\th@mb@tmp@label]{\th@mb@tmp@title}%
                       \leaders\box \ThumbsBox {\th@mbs@linefill \pageref{\th@mb@tmp@label}}%
                      }%
                    \else%
%    \end{macrocode}
%
% \item[- |line|] hyperlinks the whole \emph{line}, i.\,e. title, dots (or line or whatsoever)
%   and page numbers of the thumb marks
%
%    \begin{macrocode}
                      \def\th@mbstest{line}%
                      \ifx\thumbs@thumblink\th@mbstest%
                        {\color{\th@mb@tmp@textcolour}\noindent%
                         \hyperref[\th@mb@tmp@label]{\th@mb@tmp@title%
                         \leaders\box \ThumbsBox {\th@mbs@linefill \th@mb@tmp@page}}%
                        }%
                      \else%
%    \end{macrocode}
%
% \item[- |rule|] hyperlinks the whole \emph{rule}, but that was already done above,
%   so here no linking is done
%
%    \begin{macrocode}
                        \def\th@mbstest{rule}%
                        \ifx\thumbs@thumblink\th@mbstest%
                          {\color{\th@mb@tmp@textcolour}\noindent%
                           \th@mb@tmp@title%
                           \leaders\box \ThumbsBox {\th@mbs@linefill \th@mb@tmp@page}%
                          }%
                        \else%
%    \end{macrocode}
% \end{description}
% \newpage
% Another value for |\thumbs@thumblink| should never be encountered here.
%
%    \begin{macrocode}
                          \PackageError{thumbs}{\string\thumbs@thumblink\space invalid}{%
                            \string\thumbs@thumblink\space has an invalid value,\MessageBreak%
                            although it did not have an invalid value before,\MessageBreak%
                            and the thumbs package did not change it.\MessageBreak%
                            Therefore some other package (or the user)\MessageBreak%
                            manipulated it.\MessageBreak%
                            Now setting it to "none" as last resort.%
                            }%
                          \gdef\thumbs@thumblink{none}%
                          {\color{\th@mb@tmp@textcolour}\noindent%
                           \th@mb@tmp@title%
                           \leaders\box \ThumbsBox {\th@mbs@linefill \th@mb@tmp@page}%
                          }%
                        \fi%
                      \fi%
                    \fi%
                  \fi%
                \fi%
              \fi%
             }%
           }%
        \egroup%
      \end{thumbspicture}%
%    \end{macrocode}
%
% The thumb mark (with text) as set in the document outside of the thumb marks overview page(s)
% is also presented here, except when we are printing at the left side.
% For option |plainthumbsoverview| again the coloured background is removed.
%
%    \begin{macrocode}
      \ifx\th@mbstest\th@mbsprintpage% left page: relax.
      \else% right page
        \ifthumbs@plainthumbsoverview\relax%
          \begin{thumbspicture}[artifact](0,0)(1in+\oddsidemargin-\th@mbxpos,0)%
            {\color{\th@mb@tmp@backgroundcolour}\rule{\dimexpr\th@mbwidthx+10pt\relax}{\th@mbheighty}}%
          \end{thumbspicture}%
        \fi%
        \begin{thumbspicture}[artifact](0,0)(1in+\oddsidemargin-\th@mbxpos,-0.5\th@mbheighty+384930sp)%
          \bgroup%
            \setlength{\parindent}{0sp}%
            \setlength{\@tempdimc}{\th@mbwidthx}%
            \addtolength{\@tempdimc}{-\th@mbHitO}%
            \setlength{\@tempdimb}{\th@mbwidthx}%
            \addtolength{\@tempdimb}{-\th@mbHitE}%
            \setcounter{Th@mbTmpA}{\c@ThumbsPage}%
            \addtocounter{Th@mbTmpA}{\th@mbpofffix}%
            \ifodd\c@Th@mbTmpA\relax%
              \hspace*{-\th@mbHitO}%
              \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
            \else%
              \if@twoside%
                \hspace*{+\th@mbHitE}%
                \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{l}{\@tempdimb}%
              \else%
                \hspace*{-\th@mbHitO}%
                \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
              \fi%
            \fi%
          \egroup%
        \end{thumbspicture}%
      \fi%
    \fi%
    }%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\th@mb@yA}
% |\th@mb@yA| sets the y-position to be used in |\th@mbprint|.
%
%    \begin{macrocode}
\newcommand{\th@mb@yA}{%
  \addtolength{\th@mbposyA}{\th@mbheighty}%
  \addtolength{\th@mbposyA}{\th@mbsdistance}%
  \ifdim\th@mbposyA>\th@mbposybottom%
    \PackageWarning{thumbs}{You are not only using more than one thumb mark at one\MessageBreak%
      single page, but also thumb marks from different thumb\MessageBreak%
      columns. May I suggest the use of a \string\pagebreak\space or\MessageBreak%
      \string\newpage ?%
     }%
    \setlength{\th@mbposyA}{\th@mbposytop}%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\th@mbprint}
% |\th@mbprint| places |picture|s containing the thumb mark on the page.
% First computing some dimensions/positions. To be really safe,
% |\th@mbwidthx| is increased by $10\unit{pt}$ outside of the layout page
% (which is reverted afterwards).\newline
% The |picture| with the background of the thumb mark is placed.
%
%    \begin{macrocode}
\newcommand{\th@mbprint}[3]{%
  \setlength{\th@mbposyB}{-\th@mbposyA}%
  \addtolength{\th@mbwidthx}{+10pt}%
  \if@twoside%
    \setcounter{Th@mbTmpA}{\c@ThumbsPage}%
    \addtocounter{Th@mbTmpA}{\th@mbpofffix}%
    \ifodd\c@Th@mbTmpA\relax% right page
      \put(\th@mbxpos,\th@mbposyB){%
        \begin{thumbspicture}[artifact](0,0)%
          {\color{#3}\rule{\th@mbcomprulewidth}{\th@mbheighty}}%
        \end{thumbspicture}%
       }%
    \else% left page
      \setlength{\@tempdimc}{-\th@mbposyA}%
      \addtolength{\@tempdimc}{-\thumbs@evenprintvoffset}%
      \setlength{\th@mbposyB}{\@tempdimc}%
      \put(\th@mbxpos-10pt-\th@mbruleoutside+\th@mbwidthx,\th@mbposyB){%
        \begin{thumbspicture}[artifact](0,0)%
          {\color{#3}\rule{\th@mbcomprulewidth}{\th@mbheighty}}%
        \end{thumbspicture}%
       }%
    \fi%
  \else% one-sided, right page
    \put(\th@mbxpos,\th@mbposyB){%
      \begin{thumbspicture}[artifact](0,0)%
        {\color{#3}\rule{\th@mbcomprulewidth}{\th@mbheighty}}%
      \end{thumbspicture}%
     }%
  \fi%
  \addtolength{\th@mbwidthx}{-10pt}%
%    \end{macrocode}
%
% |\thumbs@frame| is used when the thumb marks shall only be frames and not filled.
% In this case a second, smaller |picture| is placed over the first one:
%
%    \begin{macrocode}
  \ifx\thumbs@frame\thumbs@empty\relax%
  \else%
%    \end{macrocode}
%
% \begin{description}
% \item[-] height minus two times the thickness of the line of the frame:
%
%    \begin{macrocode}
    \setlength{\th@mbiruley}{\th@mbheighty}%
    \addtolength{\th@mbiruley}{-\thumbs@frame}%
    \addtolength{\th@mbiruley}{-\thumbs@frame}%
%    \end{macrocode}
%
% \item[-] width minus two times the thickness of the line of the frame:
%
%    \begin{macrocode}
    \setlength{\th@mbirulex}{\th@mbwidthx}%
    \addtolength{\th@mbirulex}{-\thumbs@frame}%
    \addtolength{\th@mbirulex}{-\thumbs@frame}%
%    \end{macrocode}
%
% \item[-] horizontal position:
%
%    \begin{macrocode}
    \setlength{\th@mbwidthtmp}{\thumbs@frame}%
    \ifdim \th@mbxpos > 0sp\relax%
      \addtolength{\th@mbwidthtmp}{+\th@mbxpos}%
%    \end{macrocode}
%
% \begin{description}
% \item[+] right page: decreased by the length of the thumb mark going over the page's right border
%
%    \begin{macrocode}
      \addtolength{\th@mbirulex}{+\paperwidth}%
      \addtolength{\th@mbirulex}{-\th@mbxpos}%
      \addtolength{\th@mbirulex}{-\th@mbwidthx}%
    \else%
%    \end{macrocode}
%
% \item[+] left page: decreased by the length of the thumb mark going over the page's left border
%
%    \begin{macrocode}
      \addtolength{\th@mbwidthtmp}{-\th@mbxpos}%
      \addtolength{\th@mbirulex}{+\th@mbxpos}%
%    \end{macrocode}
%
% (|+\th@mbxpos|, because the value of |\th@mbxpos| is already negative or zero)
%
%    \begin{macrocode}
    \fi%
%    \end{macrocode}
%
% \end{description}
%
%    \begin{macrocode}
    \addtolength{\th@mbirulex}{-1pt}%
    \put(\th@mbwidthtmp,\th@mbposyB+\thumbs@frame){%
      \begin{thumbspicture}[artifact](0,0)%
        {\color{\th@mbs@fr@meinnercolor}\rule{\th@mbirulex}{\th@mbiruley}}%
      \end{thumbspicture}%
     }%
  \fi%
%    \end{macrocode}
% \end{description}
%
% The third picture finally contains the text:
%
%    \begin{macrocode}
  \put(\th@mbxpos,\th@mbposyB){%
    \begin{thumbspicture}[artifact](0,0)(0,-0.5\th@mbheighty+384930sp)%
      \bgroup%
        \setlength{\parindent}{0sp}%
        \setlength{\@tempdimc}{\th@mbwidthx}%
        \addtolength{\@tempdimc}{-\th@mbHitO}%
        \setlength{\@tempdimb}{\th@mbwidthx}%
        \addtolength{\@tempdimb}{-\th@mbHitE}%
        \setcounter{Th@mbTmpA}{\c@ThumbsPage}%
        \addtocounter{Th@mbTmpA}{\th@mbpofffix}%
        \ifodd\c@Th@mbTmpA\relax%
          \hspace*{-\th@mbHitO}%
          \th@mb@txtBox{#2}{#1}{r}{\@tempdimc}%
        \else%
          \if@twoside%
            \hspace*{+\th@mbHitE}%
            \th@mb@txtBox{#2}{#1}{l}{\@tempdimb}%
          \else%
            \hspace*{-\th@mbHitO}%
            \th@mb@txtBox{#2}{#1}{r}{\@tempdimc}%
          \fi%
        \fi%
      \egroup%
    \end{thumbspicture}%
   }%
  }

%    \end{macrocode}
%    \end{macro}
% \pagebreak
%
% \DescribeMacro{\AddToHook{shipout/before}}
% |\@expl@@@shipout@add@background@picture@@n| (formerly |\AtBeginShipoutUpperLeft|)
% calls the |\th@mbprint| macro for each thumb mark which shall be placed on that page.
% When |\stopthumb| was used, the thumb mark is omitted.
%
%    \begin{macrocode}
\AddToHook{shipout/before}{%
  \ifx\th@mbcolumnnew\thumbs@zero\relax% OK
  \else%
    \PackageError{thumbs}{Missing \string\addthumb\space after \string\thumbnewcolumn }{%
      Command \string\thumbnewcolumn\space was used, but no new thumb placed with \string\addthumb\MessageBreak%
      (at least not at the same page). After \string\thumbnewcolumn\space please always use an\MessageBreak%
      \string\addthumb . Until the next \string\addthumb , there will be no thumb marks on the\MessageBreak%
      pages. Starting a new column of thumb marks and not putting a thumb mark into\MessageBreak%
      that column does not make sense. If you just want to get rid of column marks,\MessageBreak%
      do not abuse \string\thumbnewcolumn\space but use \string\stopthumb .\MessageBreak%
      (This error message will be repeated at all following pages,\MessageBreak%
      \space until \string\addthumb\space is used.)%
      }%
  \fi%
  \setcounter{Th@mbTmpA}{\c@ThumbsPage}%
  \addtocounter{Th@mbTmpA}{\th@mbpofffix}%
%    \end{macrocode}
%
% Changing the paper size mid-document will probably cause some problems.
% But if it works, we try to cope with it. (When the change is performed
% without changing |\paperwidth|, we cannot detect it. Sorry.)
%
%    \begin{macrocode}
  \edef\th@mbstmpwidth{\the\paperwidth}%
  \ifdim\th@mbpaperwidth=\th@mbstmpwidth% OK
  \else%
    \PackageWarningNoLine{thumbs}{Paperwidth has changed. Thumb mark positions become now adapted}%
    \setlength{\th@mbposx}{\paperwidth}%
    \addtolength{\th@mbposx}{-\th@mbwidthx}%
    \ifthumbs@ignorehoffset%
      \addtolength{\th@mbposx}{-\hoffset}%
    \fi%
    \addtolength{\th@mbposx}{+1pt}%
    \xdef\th@mbpaperwidth{\the\paperwidth}%
  \fi%
%    \end{macrocode}
%
% Determining the correct |\th@mbxpos|:
%
%    \begin{macrocode}
  \edef\th@mbxpos{\the\th@mbposx}%
  \ifodd\c@Th@mbTmpA\relax%
  \else%
    \if@twoside%
      \ifthumbs@ignorehoffset%
         \setlength{\@tempdimc}{-\hoffset}%
         \addtolength{\@tempdimc}{-1pt}%
         \edef\th@mbxpos{\the\@tempdimc}%
      \else%
        \def\th@mbxpos{-1pt}%
      \fi%
%    \end{macrocode}
% |    \else \relax%|
%    \begin{macrocode}
    \fi%
  \fi%
  \setlength{\@tempdimc}{\th@mbxpos}%
  \if@twoside%
    \ifodd\c@Th@mbTmpA\relax%
          \addtolength{\@tempdimc}{-\th@mbHimO}%
    \else \addtolength{\@tempdimc}{+\th@mbHimE}%
    \fi%
  \else \addtolength{\@tempdimc}{-\th@mbHimO}%
  \fi%
  \edef\th@mbxpos{\the\@tempdimc}%
  \@expl@@@shipout@add@foreground@picture@@n{%
    \ifx\th@mbprinting\thumbs@one\relax%
      \th@mbprint{\th@mbtextA}{\th@mbtextcolourA}{\th@mbbackgroundcolourA}%
      \setcounter{Th@mbTmpB}{1}%
      \edef\th@mbonpagetest{\the\c@Th@mbTmpB}%
      \@whilenum\th@mbonpagetest<\th@mbonpage\do{%
        \addtocounter{Th@mbTmpB}{1}%
        \edef\th@mbonpagetest{\the\c@Th@mbTmpB}%
        \th@mb@yA%
        \def\Th@mbTmpDefText{\csname th@mbtext\AlphAlph{\the\c@Th@mbTmpB}\endcsname}%
        \def\Th@mbTmpDefColour{\csname th@mbtextcolour\AlphAlph{\the\c@Th@mbTmpB}\endcsname}%
        \def\Th@mbTmpDefBackgroundColour{\csname th@mbbackgroundcolour\AlphAlph{\the\c@Th@mbTmpB}\endcsname}%
        \th@mbprint{\Th@mbTmpDefText}{\Th@mbTmpDefColour}{\Th@mbTmpDefBackgroundColour}%
      }%
    \fi%
%    \end{macrocode}
%
% When more than one thumb mark was placed at that page, on the following pages
% only the last issued thumb mark shall appear.
%
%    \begin{macrocode}
    \setcounter{Th@mbTmpB}{\th@mbonpage}%
    \ifnum\c@Th@mbTmpB<2\relax%
    \else%
      \gdef\th@mbtextA{\th@mbtext}%
      \gdef\th@mbtextcolourA{\th@mbtextcolour}%
      \gdef\th@mbbackgroundcolourA{\th@mbbackgroundcolour}%
      \gdef\th@mbposyA{\th@mbposy}%
    \fi%
    \gdef\th@mbonpage{0}%
    \gdef\th@mbtoprint{0}%
    }%
  }

%    \end{macrocode}
% \pagebreak
%
% \DescribeMacro{Hook enddocument/afterlastpage}
% |\AddToHook{enddocument/afterlastpage}| (formerly |\AfterLastShipout|)
% is executed after the last page has been shipped out.
% It is still possible to \hbox{e.\,g.} write to the \xfile{aux} file at this time.
%
%    \begin{macrocode}
\AddToHook{enddocument/afterlastpage}{%
  \ifx\th@mbcolumnnew\thumbs@zero\relax% OK
  \else%
    \PackageWarningNoLine{thumbs}{%
      Still missing \string\addthumb\space after \string\thumbnewcolumn\space after\MessageBreak%
      last ship-out: Command \string\thumbnewcolumn\space was used,\MessageBreak%
      but no new thumb placed with \string\addthumb\space anywhere in the\MessageBreak%
      rest of the document. Starting a new column of thumb\MessageBreak%
      marks and not putting a thumb mark into that column\MessageBreak%
      does not make sense. If you just want to get rid of\MessageBreak%
      thumb marks, do not abuse \string\thumbnewcolumn\space but use\MessageBreak%
      \string\stopthumb %
     }%
  \fi%
%    \end{macrocode}
%
% After the last shipout the number of thumb marks per overview page,
% the total number of thumb marks, and the maximal thumb mark text width
% are determined and saved for the next \LaTeX\ run via the \xfile{.aux} file.
%
%    \begin{macrocode}
  \ifx\th@mbcolumn\thumbs@zero\relax% if there is only one column of thumbs
    \xdef\th@umbsperpagecount{\th@mbs}%
    \gdef\th@mbcolumn{1}%
  \fi%
  \ifx\th@umbsperpagecount\thumbs@zero\relax%
    \gdef\th@umbsperpagecount{\th@mbs}% \th@mbs was increased with each \addthumb
  \fi%
  \ifdim\th@mbmaxwidth>\th@mbwidthx%
    \ifthumbs@draft% \relax
    \else%
      \def\th@mbstest{autoauto}%
      \ifx\thumbs@width\th@mbstest%
        \AddToHook{enddocument/info}{%
          \PackageWarningNoLine{thumbs}{Rerun to get the thumb marks width right}%
         }%
      \else%
        \AddToHook{enddocument/info}{%
          \edef\thumbsinfoa{\th@mbmaxwidth}%
          \edef\thumbsinfob{\the\th@mbwidthx}%
          \PackageWarningNoLine{thumbs}{%
            Thumb mark too small or its text too wide:\MessageBreak%
            The widest thumb mark text is \thumbsinfoa\space wide,\MessageBreak%
            but the thumb marks are only \space\thumbsinfob\space wide.\MessageBreak%
            Either shorten or scale down the text,\MessageBreak%
            or increase the thumb mark width,\MessageBreak%
            or use option width=autoauto%
           }%
         }%
      \fi%
    \fi%
  \fi%
  \if@filesw%
    \immediate\write\@auxout{\string\gdef\string\th@mbmaxwidtha{\th@mbmaxwidth}}%
    \immediate\write\@auxout{\string\gdef\string\th@umbsperpage{\th@umbsperpagecount}}%
    \immediate\write\@auxout{\string\gdef\string\th@mbsmax{\th@mbs}}%
    \expandafter\newwrite\csname tf@tmb\endcsname%
%    \end{macrocode}
%
% And a rerun check is performed: Did the |\jobname.tmb| file change?
%
%    \begin{macrocode}
    \RerunFileCheck{\jobname.tmb}{\immediate\closeout \csname tf@tmb\endcsname}{%
      Warning: Rerun to get list of thumbs right!}%
    \immediate\openout \csname tf@tmb\endcsname = \jobname.tmb\relax%
 %\else there is a problem, but the according warning message was already given earlier.
  \fi%
  }

%    \end{macrocode}
%
%    \begin{macro}{\addthumbsoverviewtocontents}
% |\addthumbsoverviewtocontents| with two arguments is a replacement for
% |\addcontentsline{toc}{<level>}{<text>}|, where the first argument of
% |\addthumbsoverviewtocontents| is for |<level>| and the second for |<text>|.
% If an entry of the thumbs mark overview shall be placed in the table of contents,
% |\addthumbsoverviewtocontents| with its arguments should be used immediately before
% |\thumbsoverview|.
%
%    \begin{macrocode}
\newcommand{\addthumbsoverviewtocontents}[2]{%
  \gdef\th@mbs@toc@level{#1}%
  \gdef\th@mbs@toc@text{#2}%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\clearotherdoublepage}
% We need a command to clear a double page, thus that the following text
% is \emph{left} instead of \emph{right} as accomplished with the usual
% |\cleardoublepage|. For this we take the original |\cleardoublepage| code
% and revert the |\ifodd\c@page\else| (i.\,e. if even |\c@page|) condition.
%
%    \begin{macrocode}
\newcommand{\clearotherdoublepage}{%
\clearpage\if@twoside\ifodd\c@page% removed "\else" from \cleardoublepage
\hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi\fi\fi%
}

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\th@mbstablabeling}
% When the \xpackage{hyperref} package is used, one might like to refer to the
% thumb overview page(s) (edge index/{}indices), therefore |\th@mbstablabeling|%
% command is defined (and used later). First a~|\phantomsection| is added.
% With or without \xpackage{hyperref} a label |TableOfThumbs1| (or |TableOfThumbs2|
% or\ldots) is placed here. For compatibility with older versions of this
% package also the label |TableOfThumbs| is created. Equal to older versions
% it aims at the last used Table of Thumbs, but since version~1.0g \textbf{without}\newline
% |Error: Label TableOfThumbs multiply defined| -- thanks to |\overridelabel| from
% the \xpackage{undolabl} package.\newline
% When |\addthumbsoverviewtocontents| was used, the entry is placed into the
% table of contents.
% \pagebreak
%
%    \begin{macrocode}
\newcommand{\th@mbstablabeling}{%
  \IfPackageLoadedT{hyperref}{\phantomsection}%
  \let\label\thumbsoriglabel%
  \ifx\th@mbstable\thumbs@one\relax%
    \label{TableOfThumbs}%
    \label{TableOfThumbs1}%
  \else%
    \overridelabel{TableOfThumbs}%
    \label{TableOfThumbs\th@mbstable}%
  \fi%
  \let\label\@gobble%
  \ifx\th@mbs@toc@level\empty%\relax
  \else \addcontentsline{toc}{\th@mbs@toc@level}{\th@mbs@toc@text}%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%
% \DescribeMacro{\thumbsoverview}
% \DescribeMacro{\thumbsoverviewback}
% \DescribeMacro{\thumbsoverviewverso}
% \DescribeMacro{\thumbsoverviewdouble}
% For compatibility with documents created using older versions of this package
% |\thumbsoverview| did not get a second argument, but it is renamed to
% |\thumbsoverviewprint| and additional to |\thumbsoverview| new commands are
% introduced. It is of course also possible to use |\thumbsoverviewprint| with
% its two arguments directly, therefore its name does not include any |@|
% (saving the users the use of |\makeatother| and |\makeatletter|).
% \begin{description}
% \item[-] |\thumbsoverview| prints the thumb marks at the right side
%     and (in |twoside| mode) skips left sides (useful e.\,g.~at the beginning
%     of a document)
%
% \item[-] |\thumbsoverviewback| prints the thumb marks at the left side
%     and (in |twoside| mode) skips right sides (useful e.\,g.~at the end
%     of a document)
%
% \item[-] |\thumbsoverviewverso| prints the thumb marks at the right side
%     and (in |twoside| mode) repeats them at the next left side and so on
%     (useful anywhere in the document and when one wants to prevent empty
%      pages)
%
% \item[-] |\thumbsoverviewdouble| prints the thumb marks at the left side
%     and (in |twoside| mode) repeats them at the next right side and so on
%     (useful anywhere in the document and when one wants to prevent empty
%      pages)
% \end{description}
%
% The |\thumbsoverview...| commands are used to place the overview page(s)
% (edge index/{}indices) for the thumb marks. Their parameter is used
% to mark this page/{}these pages (e.\,g.~in the page header).
% If these marks are not wished, |\thumbsoverview...{}| will generate
% empty marks in the page header(s). |\thumbsoverview...| can be used
% more than once (for example at the beginning and at the end of the document).
% The overviews have labels |TableOfThumbs1|, |TableOfThumbs2| and so on,
% which can be referred to with e.\,g.~|\pageref{TableOfThumbs1}|.
% The reference |TableOfThumbs| (without number) aims at the last used Table of Thumbs
% (for compatibility with older versions of this package).
% \pagebreak
%
% For right-to-left writing the thumb marks must be put at the other edge of the page.
%
%    \begin{macro}{\thumbsoverview}
%    \begin{macrocode}
\newcommand{\thumbsoverview}[1]{%
  \ifthumbs@righttoleft\thumbsoverviewprint{#1}{l}%
  \else\thumbsoverviewprint{#1}{r}%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\thumbsoverviewback}
%    \begin{macrocode}
\newcommand{\thumbsoverviewback}[1]{%
  \if@twoside%
  \else%
    \PackageWarning{thumbs}{\string\thumbsoverviewback\space%
      used in a one-sided document.\MessageBreak%
      Maybe you want to use \string\thumbsoverview\space instead?\MessageBreak%
      Code}%
  \fi%
  \ifthumbs@righttoleft\thumbsoverviewprint{#1}{r}%
  \else\thumbsoverviewprint{#1}{l}%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\thumbsoverviewverso}
%    \begin{macrocode}
\newcommand{\thumbsoverviewverso}[1]{%
  \if@twoside%
  \else%
    \PackageWarning{thumbs}{\string\thumbsoverviewverso\space%
      used in a one-sided document.\MessageBreak%
      Maybe you want to use \string\thumbsoverview\space instead?\MessageBreak%
      Code}%
  \fi%
  \ifthumbs@righttoleft\thumbsoverviewprint{#1}{d}%
  \else\thumbsoverviewprint{#1}{v}%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\thumbsoverviewdouble}
%    \begin{macrocode}
\newcommand{\thumbsoverviewdouble}[1]{%
  \if@twoside%
  \else%
    \PackageWarning{thumbs}{\string\thumbsoverviewdouble\space%
      used in a one-sided document.\MessageBreak%
      Maybe you want to use \string\thumbsoverview\space instead?\MessageBreak%
      Code}%
  \fi%
  \ifthumbs@righttoleft\thumbsoverviewprint{#1}{v}%
  \else\thumbsoverviewprint{#1}{d}%
  \fi%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\thumbsoverviewprint}
% |\thumbsoverviewprint| works by calling the internal command |\th@mbs@verview|
% (see below), repeating this until all thumb marks have been processed.
%
%    \begin{macrocode}
\newcommand{\thumbsoverviewprint}[2]{%
%    \end{macrocode}
%
% It would be possible to just |\edef\th@mbsprintpage{#2}|, but
% |\thumbsoverviewprint| might be called manually and without valid second argument.
%
%    \begin{macrocode}
  \edef\th@mbstest{#2}%
  \def\th@mbstestb{r}%
  \ifx\th@mbstest\th@mbstestb% right
    \gdef\th@mbsprintpage{r}%
  \else%
    \def\th@mbstestb{l}%
    \ifx\th@mbstest\th@mbstestb% left
      \gdef\th@mbsprintpage{l}%
    \else%
      \def\th@mbstestb{v}%
      \ifx\th@mbstest\th@mbstestb% verso
        \gdef\th@mbsprintpage{v}%
      \else%
        \def\th@mbstestb{d}%
        \ifx\th@mbstest\th@mbstestb% double
          \gdef\th@mbsprintpage{d}%
        \else%
          \PackageError{thumbs}{Invalid second parameter of \string\thumbsoverviewprint }{%
            The second argument of command \string\thumbsoverviewprint\space must be\MessageBreak%
            either "r" or "l" or "v" or "d" but it is neither.\MessageBreak%
            Now "r" is chosen instead ("l" for right-to-left writing).}%
          \ifthumbs@righttoleft\gdef\th@mbsprintpage{l}%
          \else\gdef\th@mbsprintpage{r}%
          \fi%
        \fi%
      \fi%
    \fi%
  \fi%
%    \end{macrocode}
% \pagebreak
%
% Option |\thumbs@thumblink| is checked for a valid and reasonable value here.
%
%    \begin{macrocode}
  \def\th@mbstest{none}%
  \ifx\thumbs@thumblink\th@mbstest% OK
  \else%
    \IfPackageLoadedTF{hyperref}{% hyperref loaded
      \def\th@mbstest{title}%
      \ifx\thumbs@thumblink\th@mbstest% OK
      \else%
        \def\th@mbstest{page}%
        \ifx\thumbs@thumblink\th@mbstest% OK
        \else%
          \def\th@mbstest{titleandpage}%
          \ifx\thumbs@thumblink\th@mbstest% OK
          \else%
            \def\th@mbstest{line}%
            \ifx\thumbs@thumblink\th@mbstest% OK
            \else%
              \def\th@mbstest{rule}%
              \ifx\thumbs@thumblink\th@mbstest% OK
              \else%
                \PackageError{thumbs}{Option thumblink with invalid value}{%
                  Option thumblink has invalid value "\thumbs@thumblink ".\MessageBreak%
                  Valid values are "none", "title", "page",\MessageBreak%
                  "titleandpage", "line", or "rule".\MessageBreak%
                  "rule" will be used now.}%
                \gdef\thumbs@thumblink{rule}%
              \fi%
            \fi%
          \fi%
        \fi%
      \fi%
    }{% hyperref not loaded
      \PackageError{thumbs}{Option thumblink not "none", but hyperref not loaded}{%
        The option thumblink of the thumbs package was not set to "none",\MessageBreak%
        but to some kind of hyperlinks, without using package hyperref.\MessageBreak%
        Either choose option "thumblink=none", or load package hyperref.\MessageBreak%
        When pressing Return, "thumblink=none" will be set now.}%
      \gdef\thumbs@thumblink{none}%
     }%
  \fi%
%    \end{macrocode}
%
% When the thumb overview is printed and there is already a thumb mark set,
% for example for the front-matter (e.\,g.~title page, bibliographic information,
% acknowledgements, dedication, preface, abstract, tables of content, tables,
% and figures, lists of symbols and abbreviations, and the thumbs overview
% (edge index) itself, of course) or when the overview is placed near the
% end of the document, the current y-position of the thumb mark must be remembered
% (and later restored) and the printing of that thumb mark must be stopped
% (and later continued).
%
%    \begin{macrocode}
  \edef\th@mbprintingovertoc{\th@mbprinting}%
  \ifnum \th@mbsmax > \thumbs@zero\relax%
    \if@twoside%
      \def\th@mbstest{r}% right
      \ifx\th@mbstest\th@mbsprintpage%
        \ifthumbs@righttoleft\clearotherdoublepage%
        \else\cleardoublepage%
        \fi%
      \else%
        \def\th@mbstest{v}% verso
        \ifx\th@mbstest\th@mbsprintpage%
          \ifthumbs@righttoleft\clearotherdoublepage%
          \else\cleardoublepage%
          \fi%
        \else% l(eft) or d(ouble)
          \ifthumbs@righttoleft\cleardoublepage%
          \else\clearotherdoublepage%
          \fi%
        \fi%
      \fi%
    \else\clearpage%
    \fi%
    \stopthumb%
    \PackageInfo{thumbs}{If you get an error "Runaway argument? \string\MakeUppercases"\MessageBreak%
      you probably forgot the argument for a\MessageBreak%
      \string\thumbsoverview/back/verso/double\space command}%
    \markboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}%
  \fi%
  \setlength{\th@mbsposytocy}{\th@mbposy}%
  \setlength{\th@mbposy}{\th@mbsposytocyy}%
  \ifx\th@mbstable\thumbs@zero\relax%
    \newcounter{th@mblinea}%
    \newcounter{th@mblineb}%
    \newcounter{FileLine}%
    \newcounter{thumbsstop}%
  \fi%
  \setcounter{th@mblinea}{\th@mbstable}%
  \addtocounter{th@mblinea}{+1}%
  \xdef\th@mbstable{\number\value{th@mblinea}}%
  \setcounter{th@mblinea}{1}%
  \setcounter{th@mblineb}{\th@umbsperpage}%
  \setcounter{FileLine}{1}%
  \setcounter{thumbsstop}{1}%
  \addtocounter{thumbsstop}{\th@mbsmax}%
%    \end{macrocode}
% \pagebreak
%
% We do not want any labels or index or glossary entries confusing the
% table of thumb marks entries, but the commands must work outside of it:
%
%    \begin{macro}{\thumbsoriglabel}
%    \begin{macrocode}
  \let\thumbsoriglabel\label%
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\thumbsorigindex}
%    \begin{macrocode}
  \let\thumbsorigindex\index%
%    \end{macrocode}
%    \end{macro}
%    \begin{macro}{\thumbsorigglossary}
%    \begin{macrocode}
  \let\thumbsorigglossary\glossary%
%    \end{macrocode}
%    \end{macro}
%    \begin{macrocode}
  \let\label\@gobble%
  \let\index\@gobble%
  \let\glossary\@gobble%
%    \end{macrocode}
%
% Some preparation in case of double printing the overview page(s):
%
%    \begin{macrocode}
  \def\th@mbstest{v}% right left right ...
  \ifx\th@mbstest\th@mbsprintpage%
    \def\th@mbsprintpage{l}% because it will be changed to r(ight)
    \def\th@mbdoublepage{1}%
  \else%
    \def\th@mbstest{d}% left right left ...
    \ifx\th@mbstest\th@mbsprintpage%
      \def\th@mbsprintpage{r}% because it will be changed to l(eft)
      \def\th@mbdoublepage{1}%
    \else%
      \def\th@mbdoublepage{0}%
    \fi%
  \fi%
  \def\th@mb@resetdoublepage{0}%
  \@whilenum\value{FileLine}<\value{thumbsstop}\do%
%    \end{macrocode}
%
% For double printing the overview page(s) (edge index) we just change between printing
% left and right, and we need to reset the line number of the |\jobname.tmb| file
% which is read, because we need to read things twice.
%
%    \begin{macrocode}
   {\ifx\th@mbdoublepage\thumbs@one\relax%
      \def\th@mbstest{r}% right
      \ifx\th@mbsprintpage\th@mbstest%
        \def\th@mbsprintpage{l}% left
      \else% \th@mbsprintpage is l(eft)
        \def\th@mbsprintpage{r}% right
      \fi%
      \clearpage%
      \ifx\th@mb@resetdoublepage\thumbs@one\relax%
        \setcounter{th@mblinea}{\theth@mblinea}%
        \setcounter{th@mblineb}{\theth@mblineb}%
        \def\th@mb@resetdoublepage{0}%
      \else%
        \edef\theth@mblinea{\number\value{th@mblinea}}%
        \edef\theth@mblineb{\number\value{th@mblineb}}%
        \def\th@mb@resetdoublepage{1}%
      \fi%
    \else%
      \if@twoside%
        \def\th@mbstest{r}% right
        \ifx\th@mbstest\th@mbsprintpage%
          \ifthumbs@righttoleft\clearotherdoublepage%
          \else\cleardoublepage%
          \fi%
        \else% l(eft)
          \ifthumbs@righttoleft\cleardoublepage%
          \else\clearotherdoublepage%
          \fi%
        \fi%
      \else\clearpage%
      \fi%
    \fi%
%    \end{macrocode}
%
% When the very first page of a thumb marks overview is generated,
% the label is set (with the |\th@mbstablabeling| command).
%
%    \begin{macrocode}
    \ifnum\value{FileLine}=1\relax%
      \ifx\th@mbdoublepage\thumbs@one\relax%
        \ifx\th@mb@resetdoublepage\thumbs@one\relax%
          \th@mbstablabeling%
        \fi%
      \else%
        \th@mbstablabeling%
      \fi%
    \fi%
    \null%
    \th@mbs@verview%
    \pagebreak%
    \ifthumbs@verbose%
      \message{THUMBS: Fileline: \number\value{FileLine}, a: \number\value{th@mblinea}, %
        b: \number\value{th@mblineb}, per page: \th@umbsperpage, max: \th@mbsmax.^^J}%
    \fi%
%    \end{macrocode}
%
% \noindent When double page mode is active and |\th@mb@resetdoublepage| is one,
% the last page of the thumbs mark overview must be repeated, but\newline
% |  \@whilenum\value{FileLine}<\value{thumbsstop}\do|\newline
% would prevent this, because |FileLine| is already too large
% and would only be reset \emph{inside} the loop,
% but the loop would not be executed again.
% \pagebreak
%
%    \begin{macrocode}
    \ifx\th@mb@resetdoublepage\thumbs@one\relax%
      \setcounter{FileLine}{\theth@mblinea}%
    \fi%
   }%
%    \end{macrocode}
%
% After the overview, the current thumb mark (if there is any) is restored,
%
%    \begin{macrocode}
  \setlength{\th@mbposy}{\th@mbsposytocy}%
  \ifx\th@mbprintingovertoc\thumbs@one\relax%
    \continuethumb%
  \fi%
%    \end{macrocode}
%
% as well as the |\label|, |\index|, and |\glossary| commands:
%
%    \begin{macrocode}
  \let\label\thumbsoriglabel%
  \let\index\thumbsorigindex%
  \let\glossary\thumbsorigglossary%
%    \end{macrocode}
%
% and |\th@mbs@toc@level| and |\th@mbs@toc@text| need to be emptied,
% otherwise for each following Table of Thumb Marks/Edge Index the same entry
% in the table of contents would be added, if no new
% |\addthumbsoverviewtocontents| would be given.
% (But when no |\addthumbsoverviewtocontents| is given, it can be assumed
% that no |thumbsoverview|-entry shall be added to contents.)
%
%    \begin{macrocode}
  \addthumbsoverviewtocontents{}{}%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\th@mbs@verview}
%    \begin{macrocode}
\newcommand{\th@mbs@verview}{%
%    \end{macrocode}
% The internal command |\th@mbs@verview| reads a line from file |\jobname.tmb| and
% executes the content of that line~-- if that line has not been processed yet,
% in which case it is just ignored (see |\@unused|).
%
% Here was |\AddToHookNext{shipout/before}{\AtBeginShipoutUpperLeftForeground{...}}|.\newline
% If it was |\AddToHook{shipout/before}{\AtBeginShipoutUpperLeftForeground{...}}|, it could be replaced by\newline
% |\AddToHook{shipout/foreground}{...}|, but because of \textquotedblleft |Next|\textquotedblright\ it cannot.
%
%    \begin{macrocode}
  \AddToHookNext{shipout/before}{%
    \@expl@@@shipout@add@foreground@picture@@n{%
      \IfFileExists{\jobname.tmb}{% then
        \ifthumbs@verbose%
          \message{^^JPackage thumbs Info: Processing line \number\value{th@mblinea} to \number\value{th@mblineb} of \jobname.tmb.^^J}%
        \fi%
        \setcounter{FileLine}{1}%
        \openin\@instreamthumb=\jobname.tmb%
          \@whilenum\value{FileLine}<\value{th@mblineb}\do%
           {\ifthumbs@verbose%
              \message{THUMBS: Processing \jobname.tmb line \number\value{FileLine}.}%
            \fi%
            \ifnum \value{FileLine}<\value{th@mblinea}\relax%
              \read\@instreamthumb to \@unused%
              \ifthumbs@verbose\message{Can be skipped.^^J}\fi%
              % NIRVANA: ignore the line by not executing it, i.e. not executing \@unused.
              % % \@unused
            \else%
              \ifnum \value{FileLine}=\value{th@mblinea}\relax%
                \read\@instreamthumb to \@thumbsout% execute the code of this line
                \ifthumbs@verbose%
                  \message{Executing \jobname.tmb line \number\value{FileLine}.^^J}%
                \fi%
                \@thumbsout%
              \else%
                \ifnum \value{FileLine}>\value{th@mblinea}\relax%
                  \read\@instreamthumb to \@thumbsout% execute the code of this line
                  \ifthumbs@verbose%
                    \message{Executing \jobname.tmb line \number\value{FileLine}.^^J}%
                  \fi%
                  \@thumbsout%
                \else% THIS SHOULD NEVER HAPPEN!
                  \PackageError{thumbs}{Unexpected error! (Really!)}{%
                    ! You are in trouble here.\MessageBreak%
                    ! Type\space \space X \string<Return\string>\space to quit.\MessageBreak%
                    ! Delete temporary auxiliary files\MessageBreak%
                    ! (like \jobname.aux, \jobname.tmb, \jobname.out)\MessageBreak%
                    ! and retry the compilation.\MessageBreak%
                    ! If the error persists, cross your fingers\MessageBreak%
                    ! and try typing\space \space \string<Return\string>\space to proceed.\MessageBreak%
                    ! If that does not work,\MessageBreak%
                    ! please contact the maintainer of the thumbs package.\MessageBreak%
                    }%
                \fi%
              \fi%
            \fi%
            \stepcounter{FileLine}%
           }%
          \ifnum \value{FileLine}=\value{th@mblineb}\relax%
            \ifthumbs@verbose%
              \message{THUMBS: Processing \jobname.tmb line \number\value{FileLine}.}%
            \fi%
            \read\@instreamthumb to \@thumbsout% Execute the code of that line.
            \ifthumbs@verbose%
              \message{Executing \jobname.tmb line \number\value{FileLine}.^^J}%
            \fi%
            \@thumbsout%
            \stepcounter{FileLine}%
          \fi%
        \closein\@instreamthumb%
%    \end{macrocode}
%
% And on to the next overview page of thumb marks (if there are so many thumb marks):
%
%    \begin{macrocode}
        \addtocounter{th@mblinea}{\th@umbsperpage}%
        \addtocounter{th@mblineb}{\th@umbsperpage}%
        \setcounter{Th@mbTmpA}{\th@mbsmax}%
        \ifnum\value{th@mblineb}>\c@Th@mbTmpA\relax%
          \setcounter{th@mblineb}{\c@Th@mbTmpA}%
        \fi%
      }{% else
%    \end{macrocode}
%
% When |\jobname.tmb| was not found, we cannot read from that file, therefore
% the |FileLine| is set to |thumbsstop|, stopping the calling of |\th@mbs@verview|
% in |\thumbsoverview|. (And we issue a warning, of course.)
%
%    \begin{macrocode}
        \setcounter{FileLine}{\number\value{thumbsstop}}%
        \AddToHook{enddocument/info}[kernel/warnings]{%
          \PackageWarningNoLine{thumbs}{%
            File \jobname.tmb not found.\MessageBreak%
            Rerun to get thumbs overview page(s) right.%
           }%
         }%
       }%
      }%
    }%
  }

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macro}{\thumborigaddthumb}
% When we are in |draft| mode, the thumb marks are
% \textquotedblleft de-coloured\textquotedblright{},
% their width is reduced, and a warning is given.
%
%    \begin{macrocode}
\let\thumborigaddthumb\addthumb%

%    \end{macrocode}
%    \end{macro}
%
%    \begin{macrocode}
\ifthumbs@draft
  \setlength{\th@mbwidthx}{2pt}
  \renewcommand{\addthumb}[4]{\thumborigaddthumb{#1}{#2}{black}{gray}}
  \PackageWarningNoLine{thumbs}{thumbs package in draft mode:\MessageBreak%
    Thumb mark width is set to 2pt,\MessageBreak%
    thumb mark text colour to black, and\MessageBreak%
    thumb mark background colour to gray.\MessageBreak%
    Use package option final to get the original values.\MessageBreak%
   }
\fi

%    \end{macrocode}
%
% When we are in |hidethumbs| mode, there are no thumb marks
% and therefore neither any thumb mark overview page. A~warning is given.
%
%    \begin{macrocode}
\ifthumbs@hidethumbs
  \renewcommand{\addthumb}[4]{\relax}
  \PackageWarningNoLine{thumbs}{thumbs package in hide mode:\MessageBreak%
    Thumb marks are hidden.\MessageBreak%
    Set package option "hidethumbs=false" to get thumb marks%
   }
  \renewcommand{\thumbnewcolumn}{\relax}
\fi

%    \end{macrocode}
%
% \phantomsection\label{Labelpofffix}%
% To determine whether to place the thumb marks at the left or right side of
% a two{-}sided paper, \xpackage{thumbs} must determine whether the page number
% is odd or even. Because |\thepage| can be set to some value, the |ThumbsPage|
% counter is used instead. When the current page number is determined in hook
% |{shipout/before}|, it is usually already the number of the next page to be put out.
% But depending on loading of several packages and depending on the order they are loaded in,
% it is not the next page number but the current one. In earlier versions of the
% \xpackage{thumbs} package, it was checked which packages had been loaded in what order.
% When it turned out that it depended on even more packages than those
% checked for at that time, a~new procedure was introduced.
% |\AtBeginDvi|, i.\,e.~when the first page is shipped out,
% it is checked whether the |\c@ThumbsPage| current page number is odd
% \hbox{(i.\,e. 1)} or even \hbox{(i.\,e. 2} or~0) and the corresponding
% |\th@mbpofffix| is defined. For one{-}sided printing all pages are
% right ones (respectively left ones for right-to-left writing).
% Now the information about the necessary |\th@mbpofffix| is needed already earlier,
% thus it is written to the \xfile{aux} file. At the next compilation of the document
% the \xfile{aux} file will be read before beginning the first page,
% thus the information will be available.
%
%    \begin{macrocode}
\AddToHook{begindocument}[start]{%
  \AtBeginDvi{%
    \if@twoside%
      \ifodd\c@ThumbsPage\relax%
        \xdef\th@mbpofffix{0}%
      \else%
        \xdef\th@mbpofffix{1}%
      \fi%
    \else%
%    \end{macrocode}
%
% For one sided printing all pages are right pages (for left-to-right writing),
% therefore |\th@mbpofffix| does not even matter, but it needs to be defined anyway.
%
%    \begin{macrocode}
      \xdef\th@mbpofffix{0}%
    \fi%
%    \end{macrocode}
%
% For right-to-left writing we need to put the marks on the other edge of the page:
%
%    \begin{macrocode}
    \ifthumbs@righttoleft%
      \setcounter{Th@mbTmpA}{\numexpr\th@mbpofffix+1\relax}%
      \xdef\th@mbpofffix{\number\value{Th@mbTmpA}}%
    \fi%
    \if@filesw%
      \immediate\write\@auxout{\string\xdef\string\th@mbpofffix{\th@mbpofffix}}%
    \fi%
    }%
  }
%    \end{macrocode}
%    \begin{macrocode}
%</package>
%    \end{macrocode}
% \pagebreak
%
% \section{Installation}
%
% \subsection{Downloads\label{ss:Downloads}}
% Everything is available at \url{https://www.ctan.org},
% but may need additional packages themselves.\newline
%
% \DescribeMacro{thumbs.dtx}
% For unpacking the |thumbs.dtx| file and constructing the documentation it is required:
% \begin{description}
% \item[-] \TeX Format \LaTeXe{}: \url{https://www.CTAN.org}
%
% \item[-] document class \xclass{ltxdoc}, 2024/02/08, v2.1j, Standard LaTeX documentation class,
%   \url{https://www.ctan.org/pkg/ltxdoc}
%
% \item[-] package \xpackage{geometry}, 2020/01/02, v5.9, Page Geometry,
%   \url{https://www.ctan.org/pkg/geometry}
%
% \item[-] package \xpackage{holtxdoc}, 2019/12/09, v0.30, Private additional ltxdoc support (HO),
%   \url{https://www.ctan.org/pkg/holtxdoc}
% \end{description}
%
% \DescribeMacro{thumbs.sty}
% The |thumbs.sty| for \LaTeXe{} (i.\,e.~each document using the \xpackage{thumbs} package) requires:
% \begin{description}
% \item[-] \TeX{} Format \LaTeXe{}, \url{https://www.CTAN.org}
%
% \item[-] package \xpackage{xcolor}, 2024/09/29, v3.02, LaTeX color extensions (UK),
%   \url{https://www.ctan.org/pkg/xcolor}
%
% \item[-] package \xpackage{picture}, 2020-04-22, v1.6, Dimens for picture macros (HO),
%   \url{https://www.ctan.org/pkg/picture}
%
% \item[-] package \xpackage{alphalph}, 2019/12/09, v2.6, Convert numbers to letters (HO),
%   \url{http://www.ctan.org/pkg/alphalph}
%
% \item[-] package \xpackage{rerunfilecheck}, 2025-06-21, v1.11, Rerun checks for auxiliary files (HO),
%   \url{https://www.ctan.org/pkg/rerunfilecheck}
%
% \item[-] package \xpackage{pagecolor}, 2025-01-28, v1.2d, Provides thepagecolor (HMM),
%   \url{https://www.ctan.org/pkg/pagecolor}
%
% \item[-] package \xpackage{undolabl}, 2025-01-28, v1.0o, Overriding labels (HMM),
%   \url{https://www.ctan.org/pkg/undolabl}
% \end{description}
%
% \DescribeMacro{thumb-example.tex}
% The |thumb-example.tex| requires the same file as all documents using the \xpackage{thumbs} package, i.\,e.
% \begin{description}
% \item[-] package \xpackage{thumbs}, 2026-01-18, v1.1d,
%   \url{https://www.ctan.org/pkg/thumbs}\newline
%   (Well, it is the example file for this package, and because you are reading the documentation for the
%   \xpackage{thumbs} package, it~can be assumed that you already have some version of it -- is it the current one?)
% \end{description}
% and additionally:
% \begin{description}
% \item[-] package \xpackage{eurosym}, 1998/08/06, v1.1, European currency symbol
%   \textquotedblleft Euro\textquotedblright, \url{https://www.ctan.org/pkg/eurosym}
%
% \item[-] package \xpackage{lipsum}, 2021-09-20, v2.7, 150~paragraphs of Lorem Ipsum dummy text,
%    \url{https://www.ctan.org/pkg/lipsum}
%
% \item[-] package \xpackage{hyperref}, 2025-07-12, v7.01o, Hypertext links for \LaTeX,
%     \url{https://www.ctan.org/pkg/hyperref}
%
% \item[-] package \xpackage{geometry}, 2020/01/02, v5.9, Page Geometry,
%     \url{https://www.ctan.org/pkg/geometry}
% \end{description}
% \pagebreak
%
% If the printing of unchanged layout on larger physical paper shall be tested, also the \xpackage{crop}\index{crop}
% package is needed (or another package providing the same functions):
% \begin{description}
% \item[-] package \xpackage{crop}, 2017/11/19, v1.10, Crop marks (MF),
%     \url{https://www.ctan.org/pkg/crop}
% \end{description}
%
% \DescribeMacro{Alternatives}
% As possible alternatives in section~\ref{sec:Alternatives}, Alternatives, there are listed
% (newer versions might be available):
% \begin{description}
% \item[-] package \xpackage{chapterthumb}, 2005/03/10, v0.1,\newline
%   \url{https://mirror.ctan.org/info/examples/KOMA-Script-3/Anhang-B/source/chapterthumb.sty}
%
% \item[-] package \xpackage{eso-pic}, 2023-05-03, v3.0c, \url{https://www.ctan.org/pkg/eso-pic}
%
% \item[-] package \xpackage{fancytabs}, 2016/03/29, v1.9, \url{https://www.ctan.org/pkg/fancytabs}
%
% \item[-] package \xpackage{thumb}, 2001, without file version, by \textsc{Ingo Klöckel},
%  which was available at\newline
%  ftp://ftp.dante.de/pub/tex/info/examples/ltt/thumb.sty.
%
% \item[-] package \xpackage{thumb} (a completely different one), 1997/12/24, v1.0,
%   \url{https://www.ctan.org/pkg/thumb}
%
% \item[-] package \xpackage{thumbindex}, 2009/12/13, without file version,
%   \url{https://hisashim.org/2009/12/13/thumbindex.html}
%
% \item[-] thumb-indexes, from the \xpackage{fancyhdr} package, available as source code
%  in the documentation of the \xpackage{fancyhdr} package,\newline
%  \url{https://ctan.org/pkg/fancyhdr}.
%
% \item[-] package \xpackage{thumbpdf}, 2018-09-07, v3.17, \url{https://www.ctan.org/pkg/thumbpdf}
%
% \item[-] package \xpackage{thumby}, 2010/01/14, v0.1, \url{https://www.ctan.org/pkg/thumby}
% \end{description}
%
% \DescribeMacro{Münch}
% A hyperlinked list of my (other) packages can be found at \url{https://www.ctan.org/author/muench-hm}.
%
% \subsection{Package, unpacking TDS}
% \paragraph{Package.} This package is available on \url{https://www.CTAN.org}.
% \begin{description}
% \item[\url{https://mirror.ctan.org/macros/latex/contrib/thumbs/thumbs.dtx}]\hspace*{0.1cm} \newline
%       The source file.
% \item[\url{https://mirror.ctan.org/macros/latex/contrib/thumbs/thumbs.pdf}]\hspace*{0.1cm} \newline
%       The documentation.
% \item[\url{https://mirror.ctan.org/macros/latex/contrib/thumbs/thumbs-example.pdf}]\hspace*{0.1cm} \newline
%       The compiled example file, as it should look like.
% \item[\url{https://mirror.ctan.org/macros/latex/contrib/thumbs/README}]\hspace*{0.1cm} \newline
%       The README file.
% \end{description}
% There is also a |thumbs.tds.zip| available:
% \begin{description}
% \item[\url{https://mirror.ctan.org/install/macros/latex/contrib/thumbs.tds.zip}]\hspace*{0.1cm} \newline
%       Everything in TDS compliant, compiled format.
% \end{description}
% which additionally contains\newline
% \begin{tabular}{ll}
% thumbs.ins & The \texttt{ins}tallation file.\\
% thumbs.drv & The \mbox{\texttt{dr}i\texttt{v}er} to generate the documentation.\\
% thumbs.sty & The \texttt{sty}le file.\\
% thumbs-example.tex & The example file.
% \end{tabular}
%
% \bigskip
%
% \noindent For required other packages please see the preceding subsection.
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip{} archive. The files are extracted by running the
% \xext{dtx} through \plainTeX :
% \begin{quote}
%   \verb|tex thumbs.dtx|
% \end{quote}
%
% \noindent About generating the documentation see paragraph~\ref{GenDoc} below.\par
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree):
% \begin{quote}
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
%   thumbs.sty & tex/latex/thumbs/thumbs.sty\\
%   thumbs.pdf & doc/latex/thumbs/thumbs.pdf\\
%   thumbs-example.tex & doc/latex/thumbs/thumbs-example.tex\\
%   thumbs-example.pdf & doc/latex/thumbs/thumbs-example.pdf\\
%   thumbs.dtx & source/latex/thumbs/thumbs.dtx\\
% \end{tabular}^^A
% }^^A
% \sbox0{\t}^^A
% \ifdim\wd0>\linewidth
%   \begingroup
%     \advance\linewidth by\leftmargin
%     \advance\linewidth by\rightmargin
%   \edef\x{\endgroup
%     \def\noexpand\lw{\the\linewidth}^^A
%   }\x
%   \def\lwbox{^^A
%     \leavevmode
%     \hbox to \linewidth{^^A
%       \kern-\leftmargin\relax
%       \hss
%       \usebox0
%       \hss
%       \kern-\rightmargin\relax
%     }^^A
%   }^^A
%   \ifdim\wd0>\lw
%     \sbox0{\small\t}^^A
%     \ifdim\wd0>\linewidth
%       \ifdim\wd0>\lw
%         \sbox0{\footnotesize\t}^^A
%         \ifdim\wd0>\linewidth
%           \ifdim\wd0>\lw
%             \sbox0{\scriptsize\t}^^A
%             \ifdim\wd0>\linewidth
%               \ifdim\wd0>\lw
%                 \sbox0{\tiny\t}^^A
%                 \ifdim\wd0>\linewidth
%                   \lwbox
%                 \else
%                   \usebox0
%                 \fi
%               \else
%                 \lwbox
%               \fi
%             \else
%               \usebox0
%             \fi
%           \else
%             \lwbox
%           \fi
%         \else
%           \usebox0
%         \fi
%       \else
%         \lwbox
%       \fi
%     \else
%       \usebox0
%     \fi
%   \else
%     \lwbox
%   \fi
% \else
%   \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
% TDS installing feature, then some files can already be in the right
% place, see the documentation of \docstrip.
%
% \subsection{Refresh file name databases}
% If your \TeX~distribution (\TeX\,Live, \mikTeX, \dots) relies on
% file name databases, you must refresh these. For example, \TeX\,Live\ users
% run \verb|texhash| or \verb|mktexlsr|.
%
% \subsection{Some details for the interested}
% \paragraph{Unpacking with \LaTeX.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip\ and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX\ for \docstrip\ (really,
% \docstrip\ does not need \LaTeX ), then inform the autodetect routine
% about your intention:
% \begin{quote}
%   \verb|latex \let\install=y\input{thumbs.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.\label{GenDoc}}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by a
% configuration file \xfile{ltxdoc.cfg}. For instance, put the following
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
%   \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
%
% \noindent An example follows how to generate the
% documentation with \pdfLaTeX :
%
% \begin{quote}
%\begin{verbatim}
%pdflatex thumbs.dtx
%makeindex -s gind.ist thumbs.idx
%pdflatex thumbs.dtx
%makeindex -s gind.ist thumbs.idx
%pdflatex thumbs.dtx
%\end{verbatim}
% \end{quote}
%
% \subsection{Compiling the example}
%
% The example file, \textsf{thumbs-example.tex}, can be compiled \hbox{e.\,g.} via\newline
% \indent |pdflatex thumbs-example.tex|\newline
% and will need probably at least four~(!) compiler runs to get everything right.
%
% \bigskip
%
% \section{Acknowledgements}
%
% I would like to thank \textsc{Heiko Oberdiek} for providing the \xpackage{hyperref} as well as a~lot~(!)
% of other useful packages (from which I also got everything I know about creating a file in \xext{dtx} format,
% OK, say it: copying), and everybody at \url{https://tex.stackexchange.com/} for their help in all things \TeX{}
% (especially \textsc{David Carlisle} for \url{https://tex.stackexchange.com/a/45654},
% although it is no longer used in this package).
% Thanks for bug reports go to \textsc{Veronica Brandt}, \textsc{Martin Baute} (even two bug reports),
% \textsc{Su Mei Goh}, \textsc{Michael Dorner}, \textsc{Yannick Mürtz}, and \textsc{Martin Friedrich }.
% For the suggestion of new features I give thanks to \textsc{Martin Baute}, \textsc{Stephanie Hein},
% \textsc{Bjorn Victor}, \textsc{Heini Geiring}, \textsc{bplasa}, and \textsc{Su Mei Goh}.\newpage
%
% \phantomsection
% \begin{History}\label{History}
%   \begin{Version}{2010/04/01 v0.01 -- 2011/05/13 v0.46}
%     \item Diverse $\beta $-versions during the creation of this package.
%   \end{Version}
%   \begin{Version}{2011/05/14 v1.0a}
%     \item Upload to \url{https://www.ctan.org/pkg/thumbs}.
%   \end{Version}
%   \begin{Version}{2011/05/18 v1.0b}
%     \item When more than one thumb mark is places at one single page,
%             the variables containing the values (text, colour, backgroundcolour)
%             of those thumb marks are now created dynamically. Theoretically,
%             one can now have $2\,147\,483\,647$ thumb marks at one page instead of
%             six thumb marks (as with \xpackage{thumbs} version~1.0a),
%             but I am quite sure that some other limit will be reached before the
%             $2\,147\,483\,647\textsuperscript{th}$ thumb mark.
%     \item Bug fix: When a document using the \xpackage{thumbs} package was compiled,
%             and the \xfile{.aux} and \xfile{.tmb} files were created, and the
%             \xfile{.tmb} file was deleted (or renamed or moved),
%             while the \xfile{.aux} file was not deleted (or renamed or moved),
%             and the document was compiled again, and the \xfile{.aux} file was
%             reused, then reading from the then empty \xfile{.tmb} file resulted
%             in an endless loop. Fixed.
%   \end{Version}
%   \begin{Version}{2011/05/20 v1.0c}
%     \item The thumb mark width is written to the \xfile{log} file (in |verbose| mode
%             only). The knowledge of the value could be helpful for the user,
%             when option |width={auto}| was used, and one wants the thumb marks to be
%             half as big, or with double width, or a little wider, or a little
%             smaller\ldots\ Also thumb marks' height, top thumb margin and bottom thumb
%             margin are given. Look for\newline
%             |************** THUMB dimensions **************|\newline
%             in the \xfile{log} file.
%     \item Bug fix: There was a\newline
%             |  \advance\th@mbheighty-\th@mbsdistance|,\newline
%             where\newline
%             |  \advance\th@mbheighty-\th@mbsdistance|\newline
%             |  \advance\th@mbheighty-\th@mbsdistance|\newline
%             should have been, causing wrong thumb marks' height, thereby wrong number
%             of thumb marks per column, and thereby another endless loop. Fixed.
%     \item The \xpackage{ifthen} package is no longer required for the \xpackage{thumbs}
%             package, removed from its |\RequirePackage| entries.
%     \item The \xpackage{infwarerr} package is used for its |\@PackageInfoNoLine| command.
%     \item The \xpackage{warning} package is no longer used by the \xpackage{thumbs}
%             package, removed from its |\RequirePackage| entries. Instead,
%             the \xpackage{atveryend} package is used, because it is loaded anyway
%             when the \xpackage{hyperref} package is used.
%   \end{Version}
%   \begin{Version}{2011/05/26 v1.0d}
%     \item Bug fix: labels or index or glossary entries were gobbled for the thumb marks
%             overview page, but gobbling leaked to the rest of the document; fixed.
%     \item New option |silent|, complementary to old option |verbose|.
%     \item New option |draft| (and complementary option |final|), which
%             \textquotedblleft de-coloures\textquotedblright{} the thumb marks
%             and reduces their width \hbox{to $2\unit{pt}$.}
%   \end{Version}
%   \begin{Version}{2011/06/02 v1.0e}
%     \item Gobbling of labels or index or glossary entries improved.
%     \item Dimension |\thumbsinfodimen| no longer needed, removed.
%     \item Internal command |\thumbs@info| no longer needed, removed.
%     \item New value |autoauto| (not default!) for option |width|, setting the thumb marks
%             width to fit the widest thumb mark text.
%     \item When |width={autoauto}| is not used, a warning is issued, when the thumb marks
%             width is smaller than the thumb mark text.
%     \item Bug fix: Since version v1.0b as of 2011/05/18 the number of thumb marks at one
%             single page was no longer limited to six, but the example still stated this.
%             Fixed.
%   \end{Version}
%   \begin{Version}{2011/06/08 v1.0f}
%     \item Bug fix: |\th@mb@titlelabel| should be defined |\empty| at the beginning
%             of the package: fixed. (Bug reported by \textsc{Veronica Brandt}. Thanks!)
%     \item Bug fix: |\thumbs@distance| versus |\th@mbsdistance|: There should be only
%             two times |\thumbs@distance|, the value of option |distance|,
%             otherwise it should be the length |\th@mbsdistance|: fixed.
%             (Also this bug reported by \textsc{Veronica Brandt}. Thanks!)
%     \item |\hoffset| and |\voffset| are now ignored by default,
%             but can be regarded using the options |ignorehoffset=false|
%             and |ignorevoffset=false|.
%             (Pointed out again by \textsc{Veronica Brandt}. Thanks!)
%     \item Added to documentation: The package takes the dimensions |\AtBeginDocument|
%             [now: \AddToHook{begindocument}[start]],
%             thus later the page dimensions should not be changed.
%             Now explicitly stated this in the documentation.
%             |\paperwidth| changes are probably possible.
%   \end{Version}
%   \begin{Version}{2011/06/24 v1.0g}
%     \item Bug fix: When \xpackage{hyperref} was \textit{not} used,
%             then some labels were not set at all~-- fixed.
%     \item Bug fix: When more than one Table of Tumbs (edge indices) were created
%            with the |\thumbsoverview| command, there were some
%            |counter ... already defined|-errors~-- fixed.
%     \item Bug fix: When more than one Table of Tumbs were created with the
%            |\thumbsoverview| command, there was a
%            |Label TableofTumbs multiply defined|-error and it was not possible
%            to refer to any but the last Table of Tumbs. Fixed with labels
%            |TableofTumbs1|, |TableofTumbs2|,\ldots{} (|TableofTumbs| still aims
%            at the last used Table of Thumbs for compatibility.)
%     \item Bug fix: Sometimes the thumb marks were stopped one page too early
%             before the Table of Thumbs~-- fixed.
%   \end{Version}
%   \begin{Version}{2011/08/08 v1.0h}
%     \item Replaced |\global\edef| by |\xdef|.
%     \item Now using the \xpackage{pagecolor} package. Empty thumb marks now
%             inherit their colour from the pages's background. Option |pagecolor|
%             is therefore obsolete.
%     \item The \xpackage{pagesLTS} package has been replaced by the
%             \xpackage{pageslts} package.
%     \item New kinds of thumb mark overview pages introduced additionally to
%             |\thumbsoverview|: |\thumbsoverviewback|, |\thumbsoverviewverso|,
%             and |\thumbsoverviewdouble|.
%     \item New option |hidethumbs=true| to hide thumb marks (and their
%             overview page(s)).
%     \item Option |ignorehoffset| did not work for the thumb marks overview page(s)~--
%             neither |true| nor |false|; fixed.
%   \end{Version}
%   \begin{Version}{2011/08/22 v1.0i}
%     \item Hot fix: \TeX{} 2011/06/27 has changed |\enddocument| and
%             thus broken the |\AtVeryVeryEnd| command/hooking
%             of \xpackage{atveryend} package as of 2011/04/23, v1.7.
%             Version 2011/06/30, v1.8, fixed it, but this version was not available
%             at \url{CTAN.org} yet. Until then |\AtEndAfterFileList| was used.
%   \end{Version}
%   \begin{Version}{2011/10/19 v1.0j}
%     \item Changed some Warnings into Infos (as suggested by \textsc{Martin Baute}).
%     \item The SW(P)-warning is now only given |\IfFileExists{tcilatex.tex}|,
%             otherwise just a message is given. (Warning questioned by
%             \textsc{Martin Baute}.)
%     \item New option |nophantomsection| to \emph{globally} disable the automatic
%             placement of a |\phantomsection| before \emph{all} thumb marks.
%     \item New command |\thumbsnophantom| to \emph{locally} disable the automatic
%             placement of a |\phantomsection| before the \emph{next} thumb mark.
%   \end{Version}
%   \begin{Version}{2012/01/01 v1.0k}
%     \item Bugfix: Wrong installation path given in the documentation, fixed.
%     \item No longer uses the |th@mbs@tmpA| counter but uses |\@tempcnta| instead.
%     \item No longer abuses the |\th@mbposyA| dimension but |\@tempdima|.
%   \end{Version}
%   \begin{Version}{2012/01/07 v1.0l}
%     \item Bugfix: Used a |\@tempcnta| where a |\@tempdima| should have been.
%   \end{Version}
%   \begin{Version}{2012/02/23 v1.0m}
%     \item Bugfix: Replaced |\newcommand{\QTO}[2]{#2}| (for SWP) by
%             |\providecommand{\QTO}[2]{#2}|.
%     \item Bugfix: When the \xpackage{tikz} package was loaded before \xpackage{thumbs},
%             in |twoside|-mode the thumb marks were printed at the wrong side
%             of the page. (Bug reported by \textsc{Martin Baute}.) With
%             \xpackage{hyperref} it really depends on the loading order of the
%             three packages.
%     \item Now using |\ltx@ifpackageloaded| from the \xpackage{ltxcmds} package
%             to check (after |\begin{document}|) whether the \xpackage{hyperref}
%             package was loaded.
%     \item For the thumb marks |\parbox|es instead of |\makebox|es are used
%             (just in case somebody wants to place two lines into a thumb mark, e.\,g.\newline
%             |Sch |\newline
%             |St|\newline
%             in a phone book, where the other |S|es are placed in another chapter).
%   \end{Version}
%   \begin{Version}{2012/02/25 v1.0n}
%     \item Check for loading order of \xpackage{tikz} and \xpackage{hyperref} replaced
%             by robust method. (Thanks to \textsc{David Carlisle},
%             \url{https://tex.stackexchange.com/a/45654}!)\newline
%             (This was replaced in version 1.0r by a completely different method,
%             which does not test for the loading order of packages but for the
%             page number directly.)
%     \item Fixed \texttt{url}-handling in the example in case the \xpackage{hyperref}
%           package was not loaded.
%     \item In the index the line-numbers of definitions were not underlined; fixed.
%     \item In the \xfile{thumbs-example} there are now a few words about
%             \textquotedblleft paragraph-thumbs\textquotedblright{} %
%             (i.\,e.~text which is too long for the width of a thumb mark).
%   \end{Version}
%   \begin{Version}{2013/08/22 v1.0o}
%     \item \textit{This version was not released to the general public!}
%     \item \textsc{Stephanie Hein} requested the feature to be able to increase
%             the horizontal space between page edge and the text inside of the
%             thumb mark. Therefore options |evenindent| and |oddexdent| were
%             implemented (later renamed to |eventxtindent| and |oddtxtexdent|).
%     \item \textsc{Bjorn Victor} reported the same problem and also the one,
%             that two marks are not printed at the exact same vertical position
%             on recto and verso pages. Because this can be seen with a lot of
%             duplex printers, the new option |evenprintvoffset| allows to
%             vertically shift the marks on even pages by any length.
%   \end{Version}
%   \begin{Version}{2013/09/17 v1.0p}
%     \item \textit{This version was not released to the general public!}
%     \item The thumb mark text is now set in |\parbox|es everywhere.
%     \item \textsc{Heini Geiring} requested the feature to be able to
%             horizontally move the marks away from the page edge,
%             because this is useful when using brochure printing
%             where after the printing the physical page edge is changed
%             by cutting the paper. Therefore the options |evenmarkindent| and
%             |oddmarkexdent| were introduced and the options |evenindent| and
%             |oddexdent| were renamed to |eventxtindent| and |oddtxtexdent|.
%   \end{Version}
%   \begin{Version}{2014/03/09 v1.0q}
%     \item New version of the \xpackage{atveryend} package is now available at
%             \url{CTAN.org} (see entry in this history for
%             \xpackage{thumbs} version |[2011/08/22 v1.0i]|).
%     \item Support for SW(P) drastically reduced; no more testing is performed.
%     \item New option |txtcentered|: If it is set to |true|,
%             the thumb's text is centered, otherwise either |\raggedright| or
%             |\raggedleft| (depending on left or right page for double sided documents).
%     \item |\normalsize| added to prevent \textquotedblleft font size
%             leakage\textquotedblright{} from the respective page.
%     \item Handling of obsolete options (mainly from version 2013/08/22 v1.0o)
%             added.
%     \item This version has been archived at
%             \url{https://web.archive.org/web/20250808184843/https://ctan.math.illinois.edu/install/macros/latex/contrib/thumbs.tds.zip}.
%   \end{Version}
%   \begin{Version}{2015/05/25 v1.0r}
%     \item \textit{This version was, by mistake,  not released to the general public!}
%     \item Replaced code suggestion for possible compatibility with SW(P)
%             by simple warning of possible incompatibility.
%     \item \textsc{bplasa} requested the possibility to remove the coloured rules
%             behind the entries on the overview pages and to print the text there
%             in the current colour (usually black). For this the option
%             |plainthumbsoverview| (|false| by default, but |true| if used)
%             was introduced (and a spuriouse |+20pt| removed).
%             (see \hbox{p. \pageref{sss:plainthumbsoverview})}
%     \item \textsc{Bjorn Victor} suggested to use thumb marks consisting only of frames
%             instead of filled rectangles. Options |frame| and |frameinnercolor| were
%             introduced to accomplish this. (see \hbox{p. \pageref{sss:frame})}
%     \item \textsc{Su Mei Goh} requested the feature to be able to change the colour
%             of a thumb mark (text and background). Explanation added to the documentation
%             and included in the example. Not requested but also explained is now
%             the possibility to change the thumb mark text.
%             (see \hbox{p. \pageref{ss:VariableThumb})}
%     \item Bugfix: One temporary counter for two different things screwed things up;
%             fixed and replaced the two temporary counters by two \hbox{|\newcounter|s.}
%     \item Bugfix: \textsc{Su Mei Goh} reported this bug: the order, in which the packages
%             \xpackage{atbegshi} and \xpackage{pageslts} were loaded, could have caused
%             thumb marks to be placed at the wrong edge of a page (details on
%             \hbox{p. \pageref{Labelpofffix}).} Fixed this by replacing the detection,
%             which packages had been loaded and in what order, by checking
%             |\c@CurrentPage| |\AtBeginShipoutFirst|.
%     \item Bugfix: In the thumb marks overview page (edge index) on right pages
%             the rules started immediately at the text. Now they start $1\unit{em}$
%             \emph{before} the text.
%     \item Bugfix: |\MakeUppercase| missed \hbox{\textquotedblleft |{|\textquotedblright} and
%             \hbox{\textquotedblleft |}|\textquotedblright ;} fixed.
%     \item Bug circumvention: In the thumb marks overview page (edge index) on left pages
%             the rules sometimes end a bit too early. While I did not determine yet
%             why they are behaving like this, option |leftindexruleplus| allows to add
%             e.\,g.~|\evensidemargin| (or~$20\unit{pt}$ or another length) to the
%             rules (see \hbox{p. \pageref{sss:leftindexruleplus}).}
%     \item Bugfix: Option |txtcentered| was broken; fixed.
%     \item Bugfix: Some |\voffset| were off; fixed.
%     \item Blank entries on the overview pages now use |\phantom| instead of |\thepagecolor|,
%             thus overwriting of e.\,g.~a~page number or other footer material is prevented.
%     \item Explanation about thumb index and edge index added to the introduction
%             \mbox{(p. \pageref{s:Introduction}).}
%     \item Explanations about \xpackage{crop} package added (for example at p.~\pageref{ss:crop}).
%   \end{Version}
%   \begin{Version}{2025-08-01 v1.1a}
%     \item \textit{This version was intentionally not released to the general public!}
%     \item Requires \TeX-Format \LaTeX2e\ 2025-06-01.
%     \item Removed code related to now obsolete SW(P).
%     \item |\AtBeginShipoutUpperLeft| needed to be replaced by |\AtBeginShipoutUpperLeftForeground|
%             (and that by |\@expl@@@shipout@add@foreground@picture@@n|) to work with new versions
%             of \xpackage{crop} package and kernel.
%     \item Updated to current kernel and packages; now using hooks where available.
%     \item Package \xpackage{morefloats}, \url{https://www.ctan.org/pkg/morefloats}, is no longer used.
%     \item Package \xpackage{hypdoc}, \url{https://www.ctan.org/pkg/hypdoc}, is no longer used.
%     \item Package \xpackage{atbegshi}, \url{https://www.ctan.org/pkg/atbegshi}, is no longer used.
%     \item Package \xpackage{atveryend}, \url{https://www.ctan.org/pkg/atveryend}, is no longer used.
%     \item Package \xpackage{infwarerr}, \url{https://www.ctan.org/pkg/infwarerr}, is no longer used
%             but \xpackage{hyperref} does use it anyway.
%     \item Package \xpackage{ltxcmds}, \url{https://www.ctan.org/pkg/ltxcmds}, is no longer used.
%             but current \xpackage{hyperref} does use it anyway.
%   \end{Version}
%   \begin{Version}{2025-08-11 v1.1b}
%     \item \textit{This version was intentionally not released to the general public!}
%     \item New option |righttoleft| for documents using right-to-left writing,
%             placing the thumb marks at the opposite edge of the page. The \xpackage{thumbs} package now
%              should be compatible with \xpackage{polyglossia} and |Arabic| (and \XeLaTeX ).
%     \item Package \xpackage{pageslts}, \url{https://www.ctan.org/pkg/pageslts}, is no longer required
%             and therefore not loaded by \xpackage{thumbs} -- if wanted,
%             load it explicitedly in your document!
%     \item Changed (hopefully improved) really a lot of details in the code.
%     \item Updates to really a lot of details in the documentation (manual \& README).
%   \end{Version}
%   \begin{Version}{2025-12-04 v1.1c}
%     \item Minimal change in output to \xfile{log}.
%     \item Finally uploaded to CTAN.
%   \end{Version}
%   \begin{Version}{2026-01-18 v1.1d}
%     \item Package \xpackage{kvoptions}, \url{https://www.ctan.org/pkg/kvoptions}, is no longer used
%             but the required \xpackage{rerunfilecheck} package loads it.
%     \item Provided alt-text for the used |picture|-environments for compatibility with tagging.
%     \item Cleaned up the index in the documentation.
%   \end{Version}
% \end{History}
%
% When you find a mistake or have a suggestion for an improvement of this package,
% please send an e-mail to the maintainer, thanks! (Please see BUG REPORTS in the README.)
% \PrintIndex
% \Finale
\endinput