% \iffalse meta-comment
%
% File: thumbs.dtx
% Version: 2011/05/20 v1.0c
%
% Copyright (C) 2010, 2011 by
%    H.-Martin M"unch <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
%    http://www.latex-project.org/lppl/lppl-1-3c.txt
% and the latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% The Current Maintainer of this work is H.-Martin Muench.
%
% This work consists of the main source file thumbs.dtx
% and the derived files
%    thumbs.sty, thumbs.ins, thumbs.drv,
%    thumbs-example.tex, thumbs.pdf.
%
% Distribution:
%    CTAN:macros/latex/contrib/thumbs/thumbs.dtx
%    CTAN:macros/latex/contrib/thumbs/thumbs.pdf
%    CTAN:install/macros/latex/contrib/thumbs.tds.zip
%
% Unpacking:
%    (a) If thumbs.ins is present:
%           tex thumbs.ins
%    (b) Without thumbs.ins:
%           tex thumbs.dtx
%    (c) If you insist on using LaTeX
%           latex \let\install=y\input{thumbs.dtx}
%        (quote the arguments according to the demands of your shell)
%
% Documentation:
%    (a) If thumbs.drv is present:
%           (pdf)latex thumbs.drv
%           makeindex -s gind.ist thumbs.idx
%           (pdf)latex thumbs.drv
%           makeindex -s gind.ist thumbs.idx
%           (pdf)latex thumbs.drv
%    (b) Without thumbs.drv:
%           (pdf)latex thumbs.dtx
%           makeindex -s gind.ist thumbs.idx
%           (pdf)latex thumbs.dtx
%           makeindex -s gind.ist thumbs.idx
%           (pdf)latex thumbs.dtx
%
%    The class ltxdoc loads the configuration file ltxdoc.cfg
%    if available. Here you can specify further options, e.g.
%    use DIN A4 as paper format:
%       \PassOptionsToClass{a4paper}{article}
%
% Installation:
%    TDS:tex/latex/thumbs/thumbs.sty
%    TDS:doc/latex/thumbs/thumbs.pdf
%    TDS:doc/latex/thumbs/thumbs-example.tex
%    TDS:source/latex/thumbs/thumbs.dtx
%
%<*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 2011/05/20 v1.0c Thumb marks and overwiew page(s) (HMM)}
\Msg{*************************************************************************}

\keepsilent
\askforoverwritefalse

\let\MetaPrefix\relax
\preamble

This is a generated file.

Project: thumbs
Version: 2011/05/20 v1.0c

Copyright (C) 2010, 2011 by
    H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>

The usual disclaimer applys:
If it doesn't work right that's your problem.
(Nevertheless, send an e-mail to the maintainer
 when you find an error in this package.)

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3c of this license or (at your option) any later
version. This version of this license is in
   http://www.latex-project.org/lppl/lppl-1-3c.txt
and the latest version of this license is in
   http://www.latex-project.org/lppl.txt
and version 1.3c or later is part of all distributions of
LaTeX version 2005/12/01 or later.

This work has the LPPL maintenance status "maintained".

The Current Maintainer of this work is H.-Martin Muench.

This work consists of the main source file thumbs.dtx
and the derived files
   thumbs.sty, thumbs.pdf, thumbs.ins, thumbs.drv,
   thumbs-example.tex.

\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}[2009/09/24]
\ProvidesFile{thumbs.drv}%
  [2011/05/20 v1.0c Thumb marks and overwiew page(s) (HMM)]%
\documentclass[landscape]{ltxdoc}[2007/11/11]% v2.0u
\usepackage{geometry}[2010/09/12]% v5.6
\usepackage{holtxdoc}[2011/02/04]% v0.21
%% thumbs may work with earlier versions of LaTeX2e and those
%% class and packages, but this was not tested.
%% Please consider updating your LaTeX, class, and packages
%% to the most recent version (if they are not already the most
%% recent version).
\hypersetup{%
 pdfsubject={Thumb marks and overwiew page(s) (HMM)},%
 pdfkeywords={LaTeX, thumb, thumbs, thumb index, thumbs index, index, Hans-Martin Muench},%
 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}
\gdef\unit#1{\mathord{\thinspace\mathrm{#1}}}%
\begin{document}
  \DocInput{thumbs.dtx}%
\end{document}
%</driver>
%    \end{macrocode}
%
% \fi
%
% \CheckSum{1678}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \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{\\}
% \DoNotIndex{\documentclass,\usepackage,\ProvidesPackage,\begin,\end}
% \DoNotIndex{\NeedsTeXFormat,\DoNotIndex,\verb}
% \DoNotIndex{\def,\edef,\gdef,\global}
% \DoNotIndex{\ifx,\kvoptions,\listfiles,\mathord,\mathrm,\ProcessKeyvalOptions}
% \DoNotIndex{\SetupKeyvalOptions}
% \DoNotIndex{\bigskip,\space,\thinspace,\Huge,\Large,\large,\linebreak,\MessageBreak}
% \DoNotIndex{\ldots,\indent,\noindent,\newline,\pagebreak,\pagenumbering}
% \DoNotIndex{\textbf,\textit,\textsf,\texttt,\textquotedblleft,\textquotedblright}
% \DoNotIndex{\plainTeX,\TeX,\LaTeX,\pdfLaTeX}
% \DoNotIndex{\chapter,\section}
% \DoNotIndex{\arabic,\c@th@mbs@tmpA,\endcsname,\ifnum,\newpage,\setcounter,\advance}
% \DoNotIndex{\setlength,\the,\value,\textbackslash,\,}
%
% \title{The \xpackage{thumbs} package}
% \date{2011/05/20 v1.0c}
% \author{H.-Martin M\"{u}nch\\\xemail{Martin.Muench at Uni-Bonn.de}}
%
% \maketitle
%
% \begin{abstract}
% This \LaTeX\ package allows to create one or more customizable thumb index(es),
% providing a quick and easy reference methode for large documents.
% \end{abstract}
%
% \bigskip
%
% \noindent Disclaimer for web links: The author is not responsible for any contents
% referred to in this work unless he has 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 these pages.
%
% \bigskip
%
% \noindent {\color{green} Save per page about $200\unit{ml}$ water,
% $2\unit{g}$ CO$_{2}$ and $2\unit{g}$ wood:\\
% Therefore please print only if this is really necessary.}
%
% \newpage
%
% \tableofcontents
%
% \newpage
%
% \section{Introduction}
% \indent This package puts running, customizable thumb marks in 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
% e.\,g.~a~chapter is needed, for example in reference guides, anthologies,
% or quite large documents.\\
% There \emph{are} already some packages for creating thumbs, but because
% none of them did what I wanted, I wrote this new package.\footnote{Probably%
% this holds true for the motivation of the authors of quite a lot of packages.}
%
% \section{Usage}
%
% \subsection{Loading}
% \indent Load the package placing
% \begin{quote}
%   |\usepackage[<|\textit{options}|>]{thumbs}|
% \end{quote}
% \noindent in the preamble of your \LaTeXe\ source file.
%
% \subsection{Options}
% \DescribeMacro{options}
% \indent The \xpackage{thumbs} package takes the following options:
%
% \subsubsection{pagecolor\label{sss:pagecolor}}
% \DescribeMacro{pagecolor}
% \indent Option |pagecolor| wants to know the background colour of the pages
% for use with the \texttt{xcolor} package. The default value is |white|.
%
% \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{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!)
%
% \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 inch plus |\voffset| 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\\
%  |1in+\voffset+\topmargin-\thumbs@distance+\th@mbheighty+\headheight+|%
%  |\headsep+\textheight+\footskip|\newline%
%  |-\thumbs@distance-\th@mbheighty|.\\
%  Dimensions (e.\,g. $1\unit{cm}$) are also accepted.
%
% \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}
%
% \pagebreak
%
% \subsubsection{verbose\label{sss:verbose}}
% \DescribeMacro{verbose}
% \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\\
%  |************** THUMB dimensions **************|\\
%  in the \xfile{log} file for height and width of the thumb marks as well as
%  top and bottom thumb marks margins.
%
% \subsection{Commands to be used in the document}
% \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).\\
%
% \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! But for the first page the label
% \texttt{pagesLTS.0} can be use, which is already placed there by the used
% \xpackage{pagesLTS} package.\\
%
% \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.\\
%
% \DescribeMacro{\thumbsoverview}
% The command |\thumbsoverview| is used to place the overview page(s) for the thumb marks.
% Its single parameter is used to mark this page/these pages (e.\,g. in the page header).
% If these marks are not whished, |\thumbsoverview{}| will generate empty marks in the
% page header(s). |\thumbsoverview| could be used more than once (for example at the
% beginning and at the end of the document), but the label |TableOfThumbs| would than
% be multilpy defined (no great harm done, but hyperlinks will only link to one of the
% labels).\\
%
% \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|.\\
%
% \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|.
%
% \pagebreak
%
% \section{Alternatives\label{sec:Alternatives}}
%
% \begin{description}
% \item[-] \xpackage{chapterthumb}, 2005/03/10, v0.1, by \textsc{Markus Kohm}, available at\\
%  \url{http://mirror.ctan.org/info/examples/KOMA-Script-3/Anhang-B/source/chapterthumb.sty};\\
%  unfortunately without documentation, which is probably available in the book:\\
%  Kohm, M., \& Morawski, J.-U. (2008): KOMA-Script. Eine Sammlung von Klassen und Paketen f\"{u}r \LaTeX2e,
%  3.,~\"{u}berarbeitete und erweiterte Auflage f\"{u}r KOMA-Script~3,
%  Lehmanns Media, Berlin, Edition dante, ISBN-13:~978-3-86541-291-1,
%  \url{http://www.lob.de/isbn/3865412912}; in German.
%
% \item[-] \xpackage{eso-pic}, 2010/10/06, v2.0c by \textsc{Rolf Niepraschk}, available at
%  \url{http://www.ctan.org/pkg/eso-pic}, was suggested as alternative. If I understood its code right,
% |\AtBeginShipout{\AtBeginShipoutUpperLeft{\put(...| is used there, too. Thus I do not see
% its advantage. Additionally, while compiling the \xpackage{eso-pic} test documents with
% \TeX Live2010 worked, compiling them with \textsl{Scientific WorkPlace}{}\ 5.50 Build 2960\ %
% (\copyright~MacKichan Software, Inc.) led to significant deviations of the placements
% (also changing from one page to the other).
%
% \item[-] \xpackage{fancytabs}, 2011/04/16 v1.1, by \textsc{Rapha\"{e}l Pinson}, available at
%  \url{http://www.ctan.org/pkg/fancytabs}, but requires TikZ from the
%  \href{http://www.ctan.org/pkg/pgf}{pgf} bundle.
%
% \item[-] \xpackage{thumb}, 2001, without file version, by \textsc{Ingo Kl\"{o}ckel}, available at\\
%  \url{ftp://ftp.dante.de/pub/tex/info/examples/ltt/thumb.sty},
%  unfortunately without documentation, which is probably available in the book:\\
%  Kl\"{o}ckel, I. (2001): \LaTeX2e.\ Tips und Tricks, Dpunkt.Verlag GmbH,
%  \href{http://amazon.de/o/ASIN/3932588371}{ISBN-13:~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{http://www.ctan.org/pkg/thumb}.
%
% \item[-] \xpackage{thumbindex}, 2009/12/13, without file version, by \textsc{Hisashi Morita},
%  available at\\
%  \url{http://hisashim.org/2009/12/13/thumbindex.html}.
%
% \item[-] \xpackage{thumb-index}, from the \xpackage{fancyhdr} package, 2005/03/22 v3.2,
%  by~\textsc{Piet van Oostrum}, available at\\
%  \url{http://www.ctan.org/pkg/fancyhdr}.
%
% \item[-] \xpackage{thumbpdf}, 2010/07/07, v3.11, by \textsc{Heiko Oberdiek}, is for creating
%  thumbnails in a \xfile{pdf} document, not thumb marks (and therefore \textit{no} alternative);
%  available at \url{http://www.ctan.org/pkg/thumbpdf}.
%
% \item[-] \xpackage{thumby}, 2010/01/14, v0.1, by \textsc{Sergey Goldgaber},
%  \textquotedblleft is designed to work with the \href{http://www.ctan.org/pkg/memoir}{memoir}
%  class, and also requires \href{http://www.ctan.org/pkg/perltex}{Perl\TeX} and
%  \href{http://www.ctan.org/pkg/pgf}{tikz}\textquotedblright\ %
%  (\url{http://www.ctan.org/pkg/thumby}), available at \url{http://www.ctan.org/pkg/thumby}.
% \end{description}
%
% \bigskip
%
% \noindent (You programmed or found another alternative,
%  which is available at \CTAN{}?\\
%  OK, send an e-mail to me with the name, location at \CTAN{},
%  and a short notice, and I will probably include it in
%  the list above.)
%
% \newpage
%
% \section{Example}
%
%    \begin{macrocode}
%<*example>
\documentclass[twoside,british]{article}[2007/10/19]% v1.4h
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% When compiling with SWP 5.50. Build 2960 %
%% (copyright MacKichan Software, Inc.),    %
%% these additional packages are needed:    %
%% \usepackage[T1]{fontenc}                 %
%% \usepackage{amsfonts}                    %
%% \usepackage[math]{cellspace}             %
%% \usepackage{xcolor}                      %
%% \pagecolor{white}                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{lipsum}[2011/04/14]% v1.2
\usepackage{eurosym}[1998/08/06]% v1.1
\usepackage[extension=pdf,%
 pdfpagelayout=TwoPageRight,pdfpagemode={UseNone},%
 plainpages=false,%
 pdfpagelabels=true,%
 hyperindex=false,%
 pdflang={en},%
 pdftitle={thumbs package example},%
 pdfauthor={Hans-Martin Muench},%
 pdfsubject={Example for the thumbs package},%
 pdfkeywords={LaTeX, thumbs, thumb marks, Hans-Martin Muench},%
 pdfview=Fit,pdfstartview=Fit,%
 linktoc=all]{hyperref}[2011/04/17]% v6.82g
\usepackage[pagecolor=white,thumblink=rule,linefill=dots,height={auto},minheight={47pt},%
            width={auto},distance={2mm},topthumbmargin={auto},bottomthumbmargin={auto},%
            verbose=true]{thumbs}[2011/05/20]% v1.0c
\gdef\unit#1{\mathord{\thinspace\mathrm{#1}}}%
\listfiles
\begin{document}
\pagenumbering{arabic}
\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.0c as of 2011/05/20 (HMM).
The used options were \texttt{pagecolor=white},
\texttt{thumblink=rule}, \texttt{linefill=dots},
\texttt{height=auto}, \texttt{minheight=\{47pt\}},
width={auto}, \texttt{distance=\{2mm\}}, \texttt{topthumbmargin=\{auto\}},
\texttt{bottomthumbmargin=\{auto\}}, and \texttt{verbose=true}.
These are the default options, except \texttt{verbose=true}.
For more details please see the documentation!\newline

\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).\newline

\bigskip

{\color{green} Save per page about $200\unit{ml}$ water, $2\unit{g}$ CO$_{2}$
and $2\unit{g}$ wood:\newline
Therefore please print only if this is really necessary.}

\newpage

\addtitlethumb{Frontmatter}{0}{white}{gray}{pagesLTS.0}

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}{pagesLTS.0}
\end{verbatim}
was used at the beginning of this page.

\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 \textbackslash addthumbsoverviewtocontents adds the thumb
marks overview page to the table of contents.

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

That were the overview pages for the thumb marks.

\newpage

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

\begin{verbatim}
\addthumb{First section}{\space\Huge{\textbf{$1^ \textrm{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 the thumb marks
for some page(s):

\newpage

\stopthumb

The command
\begin{verbatim}
\stopthumb
\end{verbatim}
was used here. Until another 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

\continuethumb

Thumb mark continued (unchanged).

\newpage

Thumb mark continued (unchanged).

\newpage

Time for another thumb,

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

and another.

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

\addthumb{bold text }{\textbf{Bf Text}}{pink}{blue}

\addthumb{Huge Bold Text}{\Huge{\textbf{HBT}}}{black}{yellow}

When there is more than one thumb mark at one page, this is no problem.
When more than six (6) thumb marks are at one (1) page,
only the first six will be shown,
while all will appear in the thumbs overview page.
On the following pages the correct, last thumb mark will appear.
More than one thumb mark at one page probably does not make much sense.
This package was not created to create decorations at the page margin,
but if you really need more than six thumb marks at one page,
feel free to send an e-mail to the maintainer.
If you have got an idea how to dynamically create thumb
\textquotedblleft registers\textquotedblright\ (thereby overcomming
this limitation), please send an e-mail to the maintainer, too.

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

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

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 colum is started
(which will happen here).

\newpage

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

There! A new thumb colum was started automatically!

\newpage

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

You can, of course, keep the colour for more than one thumb mark.

\newpage

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

I am just adding further thumb marks.

If you are curiouse 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}$\newline
$=\frac{1}{1.\,955\,83}\,$\euro $\,=1/1.\,955\,83\unit{Euro}=1/1.\,955\,83\unit{EUR}$.

\newpage

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

I am just adding further thumb marks.

\newpage

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

Some text.

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

There! A new thumb colum was started manually!

\newpage

Some text.

\newpage

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

I just added another thumb mark.

\newpage

Well, I think that are enough thumb marks.

Good bye!

\end{document}
%</example>
%    \end{macrocode}
%
% \pagebreak
%
% \StopEventually{
% }
%
% \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}[1994/06/01]% or later
\ProvidesPackage{thumbs}[2011/05/20 v1.0c
            Thumb marks and overwiew page(s) (HMM)]

%    \end{macrocode}
%
% A short description of the \xpackage{thumbs} package:
%
%    \begin{macrocode}
%% This package allows to create a customizable thumb index,
%% providing a quick and easy reference methode for large documents,
%% as well as an overview page.

%    \end{macrocode}
%
% For SW(P) users, we issue a warning. Unfortunately, we cannot check for the used
% software (can we?), and there will be a stack overflow when using \xpackage{hyperref}
% even before the \xpackage{thumbs} package is loaded, thus the warning might not
% even reach the users. (Thus: RTFM of thumbs!)
% The options for those packages might be changed by the user -- I did not
% test all available options, thus first test, whether the document can be compiled
% with these options, and then try to change them according to your whishes.
%
%    \begin{macrocode}
\message{^^J *** Compiling with SW(P)? ^^J%
 Please see the sw(p)*.log or \jobname.log-file! *** ^^J}
\PackageWarningNoLine{thumbs}{%
  When compiling with SWP 5.50 Build 2960\MessageBreak%
  (\copyright\ MacKichan Software, Inc.),\MessageBreak%
  these additional packages are needed:\MessageBreak%
  \string\usepackage[T1]{fontenc}\MessageBreak%
  \string\usepackage{amsfonts}\MessageBreak%
  \string\usepackage[math]{cellspace}\MessageBreak%
  \string\usepackage{xcolor}\MessageBreak%
  \string\pagecolor{white}\MessageBreak%
  especially before hyperref and thumbs,\MessageBreak%
  but best right after the \string\documentclass!\MessageBreak%
 }

%    \end{macrocode}
%
% For the handling of the options we need the \xpackage{kvoptions}
% package of \textsc{Heiko Oberdiek} (see subsection~\ref{ss:Downloads}):
%
%    \begin{macrocode}
\RequirePackage{kvoptions}[2010/12/23]% v3.10
%    \end{macrocode}
%
% as well as some other packages:
%
%    \begin{macrocode}
\RequirePackage{atbegshi}[2011/01/30]% v1.15
\RequirePackage{xcolor}[2007/01/21]% v2.11
\RequirePackage{picture}[2009/10/11]% v1.3
\RequirePackage{alphalph}[2010/04/18]% v2.3
%    \end{macrocode}
%
% \pagebreak
%
% For the total number of the current page we need the \xpackage{pagesLTS}
% package of myself (see subsection~\ref{ss:Downloads}):
%
%    \begin{macrocode}
\RequirePackage{pagesLTS}[2011/03/17]% v1.1o
\RequirePackage{rerunfilecheck}[2011/04/15]% v1.7
\RequirePackage{infwarerr}[2010/04/08]% v1.3
\RequirePackage{atveryend}[2011/04/23]% v1.7
%    \end{macrocode}
%
% A last information for the user:
%
%    \begin{macrocode}
%% thumbs may work with earlier versions of those packages,
%% but this was not tested. Please consider updating your packages
%% to the most recent version (if they are not already the most
%% recent version).

%    \end{macrocode}
% See subsection~\ref{ss:Downloads} about how to get them.\\
%
% The options are introduced:
%
%    \begin{macrocode}
\SetupKeyvalOptions{family=thumbs,prefix=thumbs@}
\DeclareStringOption[white]{pagecolor}[white]% \thumbs@pagecolor
\DeclareStringOption{linefill}[dots]
\DeclareStringOption[rule]{thumblink}[rule]
\DeclareStringOption[47pt]{minheight}[47pt]
\DeclareStringOption{height}[auto]
\DeclareStringOption{width}[auto]
\DeclareStringOption{distance}[2mm]
\DeclareStringOption{topthumbmargin}[auto]
\DeclareStringOption{bottomthumbmargin}[auto]
\DeclareBoolOption[true]{verbose}

\ProcessKeyvalOptions*

%    \end{macrocode}
%
% \DescribeMacro{pagecolor}
% We set the (background) page colour to |\thumbs@pagecolor|, because the
% \texttt{xcolour} package needs a defined colour here (it~can be changed later).
%
%    \begin{macrocode}
\pagecolor{\thumbs@pagecolor}

%    \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.\MessageBreak%
        }
       \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@mbposytop
\newdimen\th@mbposybottom
\newdimen\th@mbwidthxtoc
\newdimen\th@mbsposytocy
\newdimen\th@mbsposytocyy

\newdimen\th@mbsdistance% vertical distance between thumb marks
\ifx\thumbs@distance\empty%
  \setlength{\th@mbsdistance}{1mm}
\else
  \setlength{\th@mbsdistance}{\thumbs@distance}
\fi

%    \end{macrocode}
%
% When option |verbose| was choosen, information about the thumb marks dimensions
% (and top and bottom thumb marks margin) shall be presented, but
% |\the\something@something| does not work because of |@|. Therefore we need a
% |\thumbsinfodimen| dimen and a command to set it.
%
%    \begin{macrocode}
\ifthumbs@verbose
  \newdimen\thumbsinfodimen
  \newcommand{\thumbs@info}[1]{%
    \setlength{\thumbsinfodimen}{#1}%
    }%
\else
  \PackageWarningNoLine{thumbs}{Option verbose=false found:\MessageBreak%
    You will lose some information.}
\fi

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

%    \end{macrocode}
%
% Generally it is not necessary to initialise a counter, because this is done
% automatically. But some packages change the handling of counters
% (e.\,g.~the \xpackage{localloc} package as of 1995/09/24, v1.1b), and then
% a~new counter might have a value different from zero (or the register might
% even contain something which is not a number value at all but some other
% string).
%
%    \begin{macrocode}
\newcounter{th@mbs@tmpA}
\setcounter{th@mbs@tmpA}{0}

\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{\thumbs@pagecolor}
\gdef\th@mbbackgroundcolour{\thumbs@pagecolor}
\gdef\th@mbcolumn{0}

\gdef\th@mbtextA{}
\gdef\th@mbtextcolourA{\thumbs@pagecolor}
\gdef\th@mbbackgroundcolourA{\thumbs@pagecolor}

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

\gdef\th@mbcolumnnew{0}

\gdef\thumb@two{2}% There is no \pagesLTS@two (yet).

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

%    \end{macrocode}
%
% It is checked whether writing to \jobname.tmb is allowed.
%
%    \begin{macrocode}
\if@filesw% \relax
\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}
%
% In |\setth@mbheight| the height of a thumb mark (for automatically thumb heights)
% is computed as\\
% \textquotedblleft |((Thumbs extension) / (Number of Thumbs)) - (2|
% $\times $\ |distance between Thumbs)|\textquotedblright.
%
%    \begin{macrocode}
\newcommand{\setth@mbheight}{%
  \setlength{\th@mbheighty}{\z@}
  \advance\th@mbheighty+\headheight
  \advance\th@mbheighty+\headsep
  \advance\th@mbheighty+\textheight
  \advance\th@mbheighty+\footskip
  \setcounter{th@mbs@tmpA}{\th@mbsmax}
  \ifnum\value{th@mbs@tmpA}>1
    \divide\th@mbheighty\th@mbsmax
  \fi
  \advance\th@mbheighty-\th@mbsdistance
  \advance\th@mbheighty-\th@mbsdistance
  }

%    \end{macrocode}
%
% At the beginning of the document |\AtBeginDocument| is executed.
%
%    \begin{macrocode}
\AtBeginDocument{%
  \setlength{\th@mbposyA}{1pt}
  \ifdim \thumbs@minheight < \th@mbposyA% too small
    \setlength{\thumbs@minheight}{1pt}
  \else
    \ifdim \thumbs@minheight = \th@mbposyA% small, but ok
    \else
      \ifdim \thumbs@minheight > \th@mbposyA% ok
      \else
        \PackageError{thumbs}{Option minheight has invalid value}{%
          Please use a number and a length unit (e.g. mm, cm, pt)\MessageBreak%
          and no space between as value for option minheight\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.\MessageBreak%
         }
        \setlength{\thumbs@minheight}{47pt}
      \fi
    \fi
  \fi
  \setlength{\th@mbposyA}{\thumbs@minheight}
%    \end{macrocode}
%
% This should be a temporary dimension, but we do not want to waste
% a~|newdimension|, and |\th@mbposyA| is not used here yet and
% will be set later.\\
%
% Thumb height |\th@mbheighty| is treated. If the value is empty,
% it is set to |\th@mbposyA|, which was just defined to be $47\unit{pt}$
% (by default, or to the value choosen by the user with package option
% |minheight={...}|):
%
%    \begin{macrocode}
  \ifx\thumbs@height\empty%
    \setlength{\th@mbheighty}{\th@mbposyA}
  \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 enought:\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@}
        \advance\th@mbheighty+\th@mbposyA% = \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
        \thumbs@info{\th@mbheighty}
        \PackageInfo{thumbs}{Now setting thumbs' height to \the\thumbsinfodimen .}
      \fi
      \setlength{\th@mbheighty}{\thumbs@height}
    \fi
  \fi
%    \end{macrocode}
%
% Read in the |\jobname.tmb|-file:
%
%    \begin{macrocode}
  \newread\@instreamthumb%
%    \end{macrocode}
%
% \pagebreak
%
% Inform the users about the dimensions of the thumb marks (look in the \xfile{log} file):
%
%    \begin{macrocode}
  \ifthumbs@verbose
    \message{^^J}
    \@PackageInfoNoLine{thumbs}{************** THUMB dimensions **************}
    \thumbs@info{\th@mbheighty}
    \@PackageInfoNoLine{thumbs}{The height of the thumb marks is \the\thumbsinfodimen}
  \fi
%    \end{macrocode}
%
% Setting the thumb mark width (|\th@mbwidthx|):
%
%    \begin{macrocode}
  \setlength{\th@mbwidthx}{\paperwidth}
  \advance\th@mbwidthx-\textwidth
  \divide\th@mbwidthx4
  \setlength{\th@mbposyA}{0sp}
  \ifx\thumbs@width\empty%
  \else
    \def\th@mbstest{auto}
    \ifx\thumbs@width\th@mbstest%
    \else
      \ifdim \thumbs@width > \th@mbposyA% OK
        \setlength{\th@mbwidthx}{\thumbs@width}
      \else
        \PackageError{thumbs}{Thumbs not wide enought}{%
          Option width has value '\thumbs@width'.\MessageBreak%
          This is not a valid dimension larger than zero.\MessageBreak%
          Width will be set automatically.\MessageBreak%
         }
      \fi
    \fi
  \fi
  \ifthumbs@verbose
    \thumbs@info{\th@mbwidthx}
    \@PackageInfoNoLine{thumbs}{The width of the thumb marks is \the\thumbsinfodimen}
  \fi
%    \end{macrocode}
%
% Setting the position of the first/top thumb mark. Vertical (y) position
% is a little bit complicated, because option |\thumbs@topthumbmargin| must be handeled:
%
%    \begin{macrocode}
  % Thumb position x \th@mbposx
  \setlength{\th@mbposx}{\paperwidth}
  \advance\th@mbposx-\th@mbwidthx
  \advance\th@mbposx+1pt
  % Thumb position y \th@mbposy
  \ifx\thumbs@topthumbmargin\empty%
    \def\thumbs@topthumbmargin{auto}
  \fi
  \def\th@mbstest{auto}
%    \end{macrocode}
%
% \pagebreak
%
%    \begin{macrocode}
  \ifx\thumbs@topthumbmargin\th@mbstest%
    \setlength{\th@mbposy}{1in}
    \advance\th@mbposy+\voffset
    \advance\th@mbposy+\topmargin
    \advance\th@mbposy-\thumbs@distance
    \advance\th@mbposy+\th@mbheighty
  \else
    \setlength{\th@mbposyA}{-1pt}
    \ifdim \thumbs@topthumbmargin > \th@mbposyA% OK
    \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}
    \advance\th@mbposy-\thumbs@distance
    \advance\th@mbposy+\th@mbheighty
  \fi
  \setlength{\th@mbposytop}{\th@mbposy}
  \ifthumbs@verbose%
    \setlength{\@tempdimc}{\th@mbposytop}
    \advance\@tempdimc-\th@mbheighty
    \advance\@tempdimc+\thumbs@distance
    \thumbs@info{\@tempdimc}
    \@PackageInfoNoLine{thumbs}{The top thumb margin is \the\thumbsinfodimen}
  \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}
    \advance\th@mbposybottom+\voffset
    \advance\th@mbposybottom+\topmargin
    \advance\th@mbposybottom-\thumbs@distance
    \advance\th@mbposybottom+\th@mbheighty
    \advance\th@mbposybottom+\headheight
    \advance\th@mbposybottom+\headsep
    \advance\th@mbposybottom+\textheight
    \advance\th@mbposybottom+\footskip
    \advance\th@mbposybottom-\thumbs@distance
    \advance\th@mbposybottom-\th@mbheighty
  \else
    \setlength{\th@mbposyA}{\paperheight}
    \advance\th@mbposyA-\thumbs@bottomthumbmargin
    \advance\th@mbposyA-\th@mbposytop
    \advance\th@mbposyA-\thumbs@distance
    \advance\th@mbposyA-\th@mbheighty
    \advance\th@mbposyA-\thumbs@distance
    \ifdim \th@mbposyA > 0sp%ok
    \else
      \setlength{\th@mbposyA}{\paperheight}
      \advance\th@mbposyA-\th@mbposytop
      \advance\th@mbposyA-\thumbs@distance
      \advance\th@mbposyA-\th@mbheighty
      \advance\th@mbposyA-\thumbs@distance
      \advance\th@mbposyA-1pt
      \PackageWarning{thumbs}{Thumbs column ending too high.\MessageBreak%
        Option bottomthumbmargin has value '\thumbs@bottomthumbmargin'.\MessageBreak%
        bottomthumbmargin will be set to '\the\th@mbposyA'.\MessageBreak%
       }
      \global\edef\thumbs@bottomthumbmargin{\the\th@mbposyA}
    \fi
    \setlength{\th@mbposyA}{\thumbs@bottomthumbmargin}
    \setlength{\@tempdimc}{-1pt}
    \ifdim \th@mbposyA < \@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}
    \advance\th@mbposybottom-\thumbs@bottomthumbmargin
  \fi
  \ifthumbs@verbose%
    \setlength{\@tempdimc}{\paperheight}
    \advance\@tempdimc-\th@mbposybottom
    \thumbs@info{\@tempdimc}
    \@PackageInfoNoLine{thumbs}{The bottom thumb margin is \the\thumbsinfodimen}
    \@PackageInfoNoLine{thumbs}{**********************************************}
    \message{^^J}
  \fi
%    \end{macrocode}
%
% |\th@mbposyA| is no longer used as temporary dimension here, but set to the top-most
% vertical thumb position~(y). Because it will be increased (i.\,e.~the thumb positions
% will move downwards on the page), |\th@mbsposytocyy| is used to remember this position
% unchanged.
%
%    \begin{macrocode}
  \advance\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}
%
% \DescribeMacro{\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 (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}{%
  \advance\th@mbposy+\th@mbheighty%
  \advance\th@mbposy+\th@mbsdistance%
  \ifdim\th@mbposy>\th@mbposybottom%
    \advance\th@mbposy-\th@mbheighty%
    \advance\th@mbposy-\th@mbsdistance%
  \else%
    \advance\th@mbposy-\th@mbheighty%
    \advance\th@mbposy-\th@mbsdistance%
    \addthumb{}{}{\thumbs@pagecolor}{\thumbs@pagecolor}%
    \th@mb@dvance%
  \fi%
  }

%    \end{macrocode}
%
% \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|.
%
%    \begin{macrocode}
\newcommand{\thumbnewcolumn}{%
  \ifx\th@mbtoprint\pagesLTS@one%
    \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%
     }%
    \gdef\th@mbcolumnnew{1}%
    \th@mb@dvance%
    \gdef\th@mbprinting{0}%
    \gdef\th@mbcolumnnew{2}%
  \fi%
  }

%    \end{macrocode}
%
% \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 immediately below),
% and the fifth argument consists of the label of the page, where the hyperlink
% at the thumb marks overview page shall link to. For the first page the label
% \texttt{pagesLTS.0} can be use, which is already placed there by the used
% \xpackage{pagesLTS} package.
%
%    \begin{macrocode}
\newcommand{\addtitlethumb}[5]{%
  \global\edef\th@mb@titlelabel{#5}%
  \addthumb{#1}{#2}{#3}{#4}%
  \global\edef\th@mb@titlelabel{}%
  }

%    \end{macrocode}
%
% \DescribeMacro{\addthumb}
% Now the |\addthumb| command is defined, which is used to add a new
% thumb mark to the document.
%
%    \begin{macrocode}
\newcommand{\addthumb}[4]{%
  \gdef\th@mbprinting{1}%
  \advance\th@mbposy\th@mbheighty%
  \advance\th@mbposy\th@mbsdistance%
  \ifdim\th@mbposy>\th@mbposybottom%
    \PackageWarning{thumbs}{%
      Thumbs column full, starting another column.\MessageBreak%
      }%
    \setlength{\th@mbposy}{\th@mbposytop}%
    \advance\th@mbposy\thumbs@distance%
    \ifx\th@mbcolumn\pagesLTS@zero%
      \global\edef\th@umbsperpagecount{\th@mbs}%
      \gdef\th@mbcolumn{1}%
    \fi%
  \fi%
  \setcounter{th@mbs@tmpA}{\th@mbs}%
  \addtocounter{th@mbs@tmpA}{+1}%
  \global\edef\th@mbs{\arabic{th@mbs@tmpA}}%
%    \end{macrocode}
%
% We do not want any labels or index or glossary entries confusing the
% table of thumbs entries:
%
%    \begin{macrocode}
  {\let\label\@gobble%
   \let\index\@gobble%
   \let\glossary\@gobble%
%    \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}
%
% |\@ifpackageloaded| cannot be used after |\AtBeginDocument|, so here
% it is not checked for the \xpackage{hyperref} package, but for its
% |\Hy@Warning| command. If some other package or user is defining |\Hy@Warning|,
% \xpackage{thumbs} will falsely assume, that \xpackage{hyperref} has been loaded,
% but by my humble opinion, defining |\Hy@Warning| does not make sense and
% is bad style (except definition by the \xpackage{hyperref} package itself,
% of course). Into the |\jobname.tmb| file a |\thumbcontents| entry is written.
% If \xpackage{hyperref} is found, a |\phantomsection| is placed, 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}
  \@ifundefined{Hy@Warning}{% hyperref not loaded
    }{% hyperref loaded
      \phantomsection%
      \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}}%
    \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}}%
      \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\pagesLTS@one%
  \else%
    \setcounter{th@mbs@tmpA}{\th@mbonpage}%
    \addtocounter{th@mbs@tmpA}{+1}%
    \global\edef\th@mbonpage{\arabic{th@mbs@tmpA}}%
  \fi%
  \ifx\th@mbtoprint\pagesLTS@zero%
  \else%
%    \end{macrocode}
%
% \pagebreak
%
%    \begin{macrocode}
    \ifx\th@mbcolumnnew\pagesLTS@zero%
      \PackageWarning{thumbs}{More than one thumb at one page:\MessageBreak%
        You placed more than one thumb mark (at least \th@mbonpage)\MessageBreak%
        on page \thepage \space (page is approximately).\MessageBreak%
        Maybe insert a pagebreak?\MessageBreak%
       }%
    \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\pagesLTS@zero%
    \setcounter{th@mbs@tmpA}{1}%
    \edef\th@mbonpagetest{\arabic{th@mbs@tmpA}}%
    \@whilenum\th@mbonpagetest<\th@mbonpage\do{%
      \addtocounter{th@mbs@tmpA}{1}%
      \global\edef\th@mbonpagetest{\arabic{th@mbs@tmpA}}%
      \ifnum\th@mbonpage=\th@mbonpagetest%
        \ifnum\th@mbonpagemax<\th@mbonpage%
          \global\edef\th@mbonpagemax{\th@mbonpage}%
        \fi%
        \edef\th@mbtmpdef{\csname th@mbtext\AlphAlph{\arabic{th@mbs@tmpA}}\endcsname}%
        \expandafter\gdef\th@mbtmpdef{#2}%
        \edef\th@mbtmpdef{\csname th@mbtextcolour\AlphAlph{\arabic{th@mbs@tmpA}}\endcsname}%
        \expandafter\gdef\th@mbtmpdef{#3}%
        \edef\th@mbtmpdef{\csname th@mbbackgroundcolour\AlphAlph{\arabic{th@mbs@tmpA}}\endcsname}%
        \expandafter\gdef\th@mbtmpdef{#4}%
      \fi%
    }%
    \else%
      \ifnum\th@mbonpagemax<\th@mbonpage%
        \global\edef\th@mbonpagemax{\th@mbonpage}%
      \fi%
    \fi%
  \fi%
  \ifx\th@mbcolumnnew\thumb@two% There is no \pagesLTS@two (yet).
    \gdef\th@mbcolumnnew{0}%
  \fi%
  \gdef\th@mbtoprint{1}%
  }

%    \end{macrocode}
%
% \DescribeMacro{\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}
%
% \DescribeMacro{\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}
%
% \DescribeMacro{\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 issueing blank thumbs
%   to fill a column
% \end{enumerate}
% (parameters in this order). Without \xpackage{hyperref} the $6^ \textrm{th} $ parameter
% is just ignored.
%
%    \begin{macrocode}
\newcommand{\thumbcontents}[7]{%
  \advance\th@mbposy\th@mbheighty%
  \advance\th@mbposy\th@mbsdistance%
  \ifdim\th@mbposy>\th@mbposybottom%
    \setlength{\th@mbposy}{\th@mbposytop}%
    \advance\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\thumb@two%
    \def\th@mb@tmp@column{0}%
  \fi%
  \setlength{\th@mbwidthxtoc}{\paperwidth}%
  \advance\th@mbwidthxtoc-1in%
  \advance\th@mbwidthxtoc-\hoffset%
  \advance\th@mbwidthxtoc-\oddsidemargin%
%    \end{macrocode}
%
% \pagebreak
%
%    \begin{macrocode}
  \put(1in+\hoffset+\oddsidemargin,-\th@mbposy){%
    \begin{picture}(0,0)%
%    \end{macrocode}
%
% When the option |thumblink=rule| was choosen, 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\pagesLTS@zero%
          {\color{\th@mb@tmp@backgroundcolour}\hyperref[\th@mb@tmp@label]{\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}
          {\color{\th@mb@tmp@backgroundcolour}\rule{\th@mbwidthxtoc}{\th@mbheighty}}%
        \fi%
      \else%
        {\color{\th@mb@tmp@backgroundcolour}\rule{\th@mbwidthxtoc}{\th@mbheighty}}%
      \fi%
    \end{picture}%
%    \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\pagesLTS@zero%
      \begin{picture}(0,0)(0,-0.5\th@mbheighty+384930sp)%
        \bgroup%
          \setlength{\parindent}{0pt}%
          \vbox% to \textwidth
           {\hsize=\textwidth {%
%    \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}
% 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.\MessageBreak%
                           }%
                          \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{picture}%
%    \end{macrocode}
%
% The thumb mark (with text) as set in the document outside of the thumb marks overview page(s)
% is also presented here.
%
%    \begin{macrocode}
      \begin{picture}(0,0)(1in+\hoffset+\oddsidemargin-\th@mbxpos,-0.5\th@mbheighty+384930sp)%
        \bgroup%
          \setlength{\parindent}{0pt}%
          \makebox[\th@mbwidthx][r]{{\color{\th@mb@tmp@textcolour}\th@mb@tmp@text \space}}%
        \egroup%
      \end{picture}%
    \fi%
    }%
  }

%    \end{macrocode}
%
% \DescribeMacro{\th@mb@yA}
% |\th@mb@yA| sets the y-position to be used in |\th@mbprint|.
%
%    \begin{macrocode}
\newcommand{\th@mb@yA}{%
  \advance\th@mbposyA\th@mbheighty%
  \advance\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}
%
% \pagebreak
%
% \DescribeMacro{\th@mbprint}
% |\th@mbprint| places a |picture| containing the thumb mark on the page.
%
%    \begin{macrocode}
\newcommand{\th@mbprint}[3]{%
  \put(\th@mbxpos,-\th@mbposyA){%
    \begin{picture}(0,0)%
      {\color{#3}\rule{\th@mbwidthx}{\th@mbheighty}}%
   \end{picture}%
   \begin{picture}(0,0)(0,-0.5\th@mbheighty+384930sp)%
     \bgroup%
       \setlength{\parindent}{0pt}%
       \ifodd\c@CurrentPage%
         \if@twoside%
           \makebox[\th@mbwidthx][l]{{\color{#2}\hspace*{1pt}\space #1}}%
         \else%
           \makebox[\th@mbwidthx][r]{{\color{#2}#1\space}}%
         \fi%
       \else%
         \makebox[\th@mbwidthx][r]{{\color{#2}#1\space}}%
       \fi%
     \egroup%
   \end{picture}%
  }%
 }

%    \end{macrocode}
%
% \DescribeMacro{\AtBeginShipout}
% |\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}
\AtBeginShipout{%
  \ifx\th@mbcolumnnew\pagesLTS@zero% 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.)\MessageBreak%
     }%
  \fi%
  \setcounter{th@mbs@tmpA}{\value{CurrentPage}}%
  \addtocounter{th@mbs@tmpA}{-1}% because CurrentPage is already the one of the next page
  \def\th@mbxpos{\th@mbposx}%
  \ifodd\c@th@mbs@tmpA% \relax
  \else%
    \if@twoside \def\th@mbxpos{-1pt}% \else \relax
    \fi%
  \fi%
  \AtBeginShipoutUpperLeft{%
    \ifx\th@mbprinting\pagesLTS@one%
      \th@mbprint{\th@mbtextA}{\th@mbtextcolourA}{\th@mbbackgroundcolourA}%
      \setcounter{th@mbs@tmpA}{1}%
      \edef\th@mbonpagetest{\arabic{th@mbs@tmpA}}%
      \@whilenum\th@mbonpagetest<\th@mbonpage\do{%
        \addtocounter{th@mbs@tmpA}{1}%
        \edef\th@mbonpagetest{\arabic{th@mbs@tmpA}}%
        \th@mb@yA%
        \def\th@mbtmpdeftext{\csname th@mbtext\AlphAlph{\arabic{th@mbs@tmpA}}\endcsname}%
        \def\th@mbtmpdefcolour{\csname th@mbtextcolour\AlphAlph{\arabic{th@mbs@tmpA}}\endcsname}%
        \def\th@mbtmpdefbackgroundcolour{\csname th@mbbackgroundcolour\AlphAlph{\arabic{th@mbs@tmpA}}\endcsname}%
        \th@mbprint{\th@mbtmpdeftext}{\th@mbtmpdefcolour}{\th@mbtmpdefbackgroundcolour}%
      }%
    \fi%
    \setcounter{th@mbs@tmpA}{\th@mbonpage}%
%    \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}
    \ifnum\value{th@mbs@tmpA}<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}
%
% \DescribeMacro{\AfterLastShipout}
%
%    \begin{macrocode}
\AfterLastShipout{%
  \ifx\th@mbcolumnnew\pagesLTS@zero% ok
  \else
    \PackageWarningNoLine{thumbs}{%
      Still missing \string\addthumb\space after \string\thumbnewcolumn\space after\MessageBreak%
      last shipout: 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}
%
% |\AfterLastShipout| the number of thumb marks per overview page
% and the total number of thumb marks are determined and saved
% for the next \LaTeX\ run via the \xfile{.aux} file.
%
%    \begin{macrocode}
  \ifx\th@mbcolumn\pagesLTS@zero% if there is only one column of thumbs
    \global\edef\th@umbsperpagecount{\th@mbs}
    \gdef\th@mbcolumn{1}
  \fi
  \ifx\th@umbsperpagecount\pagesLTS@zero
    \gdef\th@umbsperpagecount{\th@mbs}% \th@mbs was increased with each \addthumb
  \fi
  \if@filesw
    \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}
%
% \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|.
%
%    \begin{macrocode}
\newcommand{\addthumbsoverviewtocontents}[2]{%
  \gdef\th@mbs@toc@level{#1}
  \gdef\th@mbs@toc@text{#2}
  }

%    \end{macrocode}
%
% \pagebreak
%
% \DescribeMacro{\thumbsoverview}
% |\thumbsoverview| is used to place the overview page(s) for the thumb marks.
% Its parameter is used to mark this page/these pages (e.\,g. in the page header).
% If these marks are not whished, |\thumbsoverview{}| will generate empty marks in the
% page header(s). |\thumbsoverview| could be used more than once (for example at the
% beginning and at the end of the document), but the label |TableOfThumbs| would than
% be multilpy defined (no great harm done, but hyperlinks will only link to one of the
% labels). |\thumbsoverview| works by calling the internal command |\th@mbs@verview|
% (see below), repeating this until all thumb marks have been processed.
%
%    \begin{macrocode}
\newcommand{\thumbsoverview}[1]{%
%    \end{macrocode}
%
% Option |\thumbs@thumblink| is checked for a valid and resonable value here.
%
%    \begin{macrocode}
  \def\th@mbstest{none}%
  \ifx\thumbs@thumblink\th@mbstest% OK
  \else%
    \@ifundefined{Hy@Warning}{% hyperref not loaded
      \PackageError{thumbs}{Option thumblink != 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.\MessageBreak%
        }%
      \gdef\thumbs@thumblink{none}%
      }{% 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 value '\thumbs@thumblink'.\MessageBreak%
                  Valid values are 'none', 'title', 'page',\MessageBreak%
                  'titleandpage', 'line', or 'rule'.\MessageBreak%
                  'rule' will be used now.\MessageBreak%
                  }%
                \gdef\thumbs@thumblink{rule}%
              \fi%
            \fi%
          \fi%
        \fi%
      \fi%
    }%
  \fi%
%    \end{macrocode}
%
% When the thumb overview is printed and there is already a thumb mark set,
% for example for the frontmatter (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 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}%
  \stopthumb%
  \markboth{\MakeUppercase #1 }{\MakeUppercase #1 }
  \setlength{\th@mbsposytocy}{\th@mbposy}
  \setlength{\th@mbposy}{\th@mbsposytocyy}
  \newcounter{th@mblinea}
  \setcounter{th@mblinea}{1}
  \newcounter{th@mblineb}
  \setcounter{th@mblineb}{\th@umbsperpage}
  \newcounter{FileLine}
  \setcounter{FileLine}{1}
  \newcounter{thumbsstop}
  \setcounter{thumbsstop}{1}
  \addtocounter{thumbsstop}{\th@mbsmax}
  \@whilenum\value{FileLine}<\value{thumbsstop}\do%
   {\if@twoside \cleardoublepage%
    \else \clearpage%
    \fi%
%    \end{macrocode}
%
% When the \xpackage{hyperref} package is used, one might like to refer to the
% thumb overview page(s), therefore a phantomsection is added and a label
% |TableOfThumbs| is placed here. When |\addthumbsoverviewtocontents| was used,
% the entry is placed into the table of contents.
%
%    \begin{macrocode}
    \ifnum\value{FileLine}=1%
      \@ifundefined{Hy@Warning}{}{\phantomsection \label{TableOfThumbs}}%
      \ifx\th@mbs@toc@level\empty%
      \else \addcontentsline{toc}{\th@mbs@toc@level}{\th@mbs@toc@text}%
      \fi%
    \fi%
    \null%
    \th@mbs@verview%
    \pagebreak%
    \ifthumbs@verbose%
      \message{THUMBS: Fileline: \arabic{FileLine}, a: \arabic{th@mblinea}, %
        b: \arabic{th@mblineb}, per page: \th@umbsperpage, max: \th@mbsmax.^^J}%
    \fi%
   }%
%    \end{macrocode}
%
% \pagebreak
%
% After the overview, the current thumb mark (if there is any) is restored.
%
%    \begin{macrocode}
  \setlength{\th@mbposy}{\th@mbsposytocy}%
  \ifx\th@mbprintingovertoc\pagesLTS@one%
    \continuethumb%
  \fi%
  }

%    \end{macrocode}
%
% \DescribeMacro{\th@mbs@verview}
% 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|).
%
%    \begin{macrocode}
\newcommand{\th@mbs@verview}{%
  \ifthumbs@verbose%
    \message{^^JPackage thumbs Info: Processing line \arabic{th@mblinea} to \arabic{th@mblineb} of \jobname.tmb.}%
  \fi%
  \setcounter{FileLine}{1}%
  \AtBeginShipoutNext{%
    \AtBeginShipoutUpperLeftForeground{%
      \IfFileExists{\jobname.tmb}{% then
        \openin\@instreamthumb=\jobname.tmb %
          \@whilenum\value{FileLine}<\value{th@mblineb}\do%
           {\ifthumbs@verbose%
              \message{THUMBS: Processing \jobname.tmb line \arabic{FileLine}.}%
            \fi%
            \ifnum \value{FileLine}<\value{th@mblinea}%
              \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}%
                \read\@instreamthumb to \@thumbsout% execute the code of this line
                \ifthumbs@verbose%
                  \message{Executing \jobname.tmb line \arabic{FileLine}.^^J}%
                \fi%
                \@thumbsout%
              \else%
                \ifnum \value{FileLine}>\value{th@mblinea}%
                  \read\@instreamthumb to \@thumbsout% execute the code of this line
                  \ifthumbs@verbose%
                    \message{Executing \jobname.tmb line \arabic{FileLine}.^^J}%
                  \fi%
                  \@thumbsout%
%    \end{macrocode}
%
% \pagebreak
%
%    \begin{macrocode}
                \else% THIS SHOULD NEVER HAPPEN!
                  \PackageError{thumbs}{Unexpected error! (Really!)}{%
                    ! You are in trouble here.\MessageBreak%
                    ! Type  X \string<return\string>  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  \string<return\string>  to proceed.\MessageBreak%
                    ! If that does not work,\MessageBreak%
                    ! you might contact the maintainer of the thumbs package.\MessageBreak%
                    }%
                \fi%
              \fi%
            \fi%
            \stepcounter{FileLine}%
           }%
          \ifnum \value{FileLine}=\value{th@mblineb}
            \ifthumbs@verbose%
              \message{THUMBS: Processing \jobname.tmb line \arabic{FileLine}.}%
            \fi%
            \read\@instreamthumb to \@thumbsout% Execute the code of that line.
            \ifthumbs@verbose%
              \message{Executing \jobname.tmb line \arabic{FileLine}.^^J}%
            \fi%
            \@thumbsout% Well, really execute it here.
            \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@mbs@tmpA}{\th@mbsmax}%
        \ifnum \value{th@mblineb}>\value{th@mbs@tmpA}
          \setcounter{th@mblineb}{\value{th@mbs@tmpA}}%
        \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}{\arabic{thumbsstop}}%
        \AtVeryVeryEnd{%
          \PackageWarningNoLine{thumbs}{%
            File \jobname.tmb not found.\MessageBreak%
            Rerun to get thumbs overview page(s) right.\MessageBreak%
           }%
         }%
       }%
      }%
    }%
  }

%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \bigskip
%
% \section{Installation}
%
% \subsection{Downloads\label{ss:Downloads}}
%
% Everything is available on \CTAN{}, \url{http://www.ctan.org/tex-archive/},
% but may need additional packages themselves.\\
%
% \DescribeMacro{thumbs.dtx}
% For unpacking the |thumbs.dtx| file and constructing the documentation it is required:
% \begin{description}
% \item[-] \TeX Format \LaTeXe: \url{http://www.CTAN.org/}
%
% \item[-] document class \textsf{ltxdoc}, 2007/11/11, v2.0u, \CTAN{macros/latex/base/ltxdoc.dtx}
%
% \item[-] package \xpackage{geometry}, 2010/09/12, v5.6, \CTAN{macros/latex/contrib/geometry/geometry.dtx}
%
% \item[-] package \xpackage{holtxdoc}, 2011/02/04, v0.21, \CTAN{macros/latex/contrib/oberdiek/holtxdoc.dtx}
%
% \item[-] package \xpackage{hypdoc}, 2010/03/26, v1.9, \CTAN{macros/latex/contrib/oberdiek/hypdoc.dtx}
% \end{description}
%
% \DescribeMacro{thumbs.sty}
% The \texttt{thumbs.sty} for \LaTeXe\ (i.\,e. all documents using
% the \xpackage{thumbs} package) requires:
% \begin{description}
% \item[-] \TeX Format \LaTeXe, \url{http://www.CTAN.org/}
%
% \item[-] package \xpackage{xcolor}, 2007/01/21, v2.11, \CTAN{macros/latex/contrib/xcolor/xcolor.dtx}
%
% \item[-] package \xpackage{pagesLTS}, 2011/03/17, v1.1o, \CTAN{macros/latex/contrib/pageslts/pagesLTS.dtx}
%
% \item[-] package \xpackage{alphalph}, 2010/04/18, v2.3, \CTAN{macros/latex/contrib/oberdiek/alphalph.dtx}
%
% \item[-] package \xpackage{atbegshi}, 2011/01/30, v1.15, \CTAN{macros/latex/contrib/oberdiek/atbegshi.dtx}
%
% \item[-] package \xpackage{atveryend}, 2011/04/23, v1.7, \CTAN{macros/latex/contrib/oberdiek/atveryend.dtx}
%
% \item[-] package \xpackage{infwarerr}, 2010/04/08, v1.3, \CTAN{macros/latex/contrib/oberdiek/infwarerr.dtx}
%
% \item[-] package \xpackage{kvoptions}, 2010/12/23, v3.10, \CTAN{macros/latex/contrib/oberdiek/kvoptions.dtx}
%
% \item[-] package \xpackage{picture}, 2009/10/11, v1.3, \CTAN{macros/latex/contrib/oberdiek/picture.dtx}
%
% \item[-] package \xpackage{rerunfilecheck}, 2011/04/15, v1.7, \CTAN{macros/latex/contrib/oberdiek/rerunfilecheck.dtx}
% \end{description}
%
% \pagebreak
%
% \DescribeMacro{SW/SWP}
% When compiling with SWP 5.50 Build 2960 (\copyright~MacKichan Software, Inc.),
% these additional packages are needed:
%
% \begin{quote}
%\begin{verbatim}
%\usepackage[T1]{fontenc}
%\usepackage{amsfonts}
%\usepackage[math]{cellspace}
%\usepackage{xcolor}
%\pagecolor{white}
%\end{verbatim}
% \end{quote}
%
% \noindent especially before \xpackage{hyperref} and \xpackage{thumbs}, but best right after the |\documentclass|!
% (The options for those packages might be changed by the user -- I did not test all available options,
%  thus first test, whether the document can be compiled with these options, and then try to change them
%  according to your whishes.)\\
%
% \DescribeMacro{thumb-example.tex}
% The |thumb-example.tex| requires the same files as all documents using the \xpackage{thumbs}
% package and additionally:
% \begin{description}
% \item[-] package \xpackage{eurosym}, 1998/08/06, v1.1, \CTAN{fonts/eurosym.zip}

% \item[-] package \xpackage{lipsum}, 2011/04/14, v1.2, \CTAN{macros/latex/contrib/lipsum/lipsum.dtx}
%
% \item[-] package \xpackage{hyperref}, 2011/04/17, v6.82g, \CTAN{macros/latex/contrib/hyperref/hyperref.dtx}
%
% \item[-] package \xpackage{thumbs}, 2011/05/20, v1.0c, \CTAN{macros/latex/contrib/thumbs/thumbs.dtx}\\
%   (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}
%
% \DescribeMacro{Alternatives}
% As possible alternatives in section \ref{sec:Alternatives} there are listed
% \begin{description}
% \item[-] \xpackage{chapterthumb}, 2005/03/10, v0.1, \CTAN{info/examples/KOMA-Script-3/Anhang-B/source/chapterthumb.sty}
%
% \item[-] \xpackage{eso-pic}, 2010/10/06, v2.0c, \CTAN{macros/latex/contrib/eso-pic/eso-pic.dtx}
%
% \item[-] \xpackage{fancytabs}, 2011/04/16 v1.1, \CTAN{macros/latex/contrib/fancytabs/fancytabs.dtx}
%
% \item[-] \xpackage{thumb}, 2001, without file version, \url{ftp://ftp.dante.de/pub/tex/info/examples/ltt/thumb.sty}
%
% \item[-] \xpackage{thumb} (a completely different one), 1997/12/24, v1.0, \CTAN{macros/latex/contrib/thumb/thumb.dtx}
%
% \item[-] \xpackage{thumbindex}, 2009/12/13, without file version, \url{http://hisashim.org/2009/12/13/thumbindex.html}.
%
% \item[-] \xpackage{thumb-index}, from the \xpackage{fancyhdr} package, 2005/03/22 v3.2,
%  \CTAN{macros/latex/contrib/fancyhdr/fancyhdr.pdf}
%
% \item[-] \xpackage{thumbpdf}, 2010/07/07, v3.11, \CTAN{support/thumbpdf/thumbpdf.sty}
%
% \item[-] \xpackage{thumby}, 2010/01/14, v0.1, \CTAN{macros/latex/contrib/thumby/thumby.sty}
% \end{description}
%
% \pagebreak
%
% \DescribeMacro{Oberdiek}
% \DescribeMacro{holtxdoc}
% \DescribeMacro{alphalph}
% \DescribeMacro{atbegshi}
% \DescribeMacro{atveryend}
% \DescribeMacro{infwarerr}
% \DescribeMacro{kvoptions}
% \DescribeMacro{picture}
% \DescribeMacro{rerunfilecheck}
% All packages of \textsf{Heiko Oberdiek}'s bundle `oberdiek'
% (especially \xpackage{holtxdoc}, \xpackage{alphalph}, \xpackage{atbegshi}, \xpackage{infwarerr},
%  \xpackage{kvoptions}, \xpackage{picture}, and \xpackage{rerunfilecheck})
% are also available in a TDS compliant ZIP archive:\\
% \CTAN{install/macros/latex/contrib/oberdiek.tds.zip}.\\
% It is probably best to download and use this, because the packages in there
% should be both recent and compatible.\\
%
% \vspace{6em}
%
% \DescribeMacro{hyperref}
% \noindent \textsf{Heiko Oberdiek}'s \xpackage{hyperref} package is not included in that bundle
% but needs to be downloaded separately,\\
% \url{http://mirror.ctan.org/install/macros/latex/contrib/hyperref.tds.zip}.\\
%
% \DescribeMacro{M\"{u}nch}
% A hyperlinked list of my (other) packages can be found at \url{http://www.Uni-Bonn.de/~uzs5pv/LaTeX.html}.
%
% \subsection{Package, unpacking TDS}
%
% \paragraph{Package.} This package should be available on \CTAN{}:
% \begin{description}
% \item[\CTAN{macros/latex/contrib/thumbs/thumbs.dtx}]\hspace*{0.1cm} \\
%       The source file.
% \item[\CTAN{macros/latex/contrib/thumbs/thumbs.pdf}]\hspace*{0.1cm} \\
%       The documentation.
% \item[\CTAN{macros/latex/contrib/thumbs/thumbs-example.pdf}]\hspace*{0.1cm} \\
%       The compiled example file, as it should look like.
% \item[\CTAN{macros/latex/contrib/thumbs/README}]\hspace*{0.1cm} \\
%       The README file.
% \item[\CTAN{install/macros/latex/contrib/thumbs.tds.zip}]\hspace*{0.1cm} \\
%       Everything in TDS compliant, compiled format,
% \end{description}
% which additionally contains\\
% \begin{tabular}{ll}
% thumbs.ins & The installation file.\\
% thumbs.drv & The driver to generate the documentation.\\
% thumbs.sty &  The \xext{sty}le file.\\
% thumbs-example.tex & The example file.%
% \end{tabular}
%
% \bigskip
%
% \noindent For required other packages, see the preceding subsection.
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip\ archive. The files are extracted by running the
% \xfile{.dtx} through \plainTeX:
% \begin{quote}
%   \verb|tex thumbs.dtx|
% \end{quote}
%
% About generating the documentation see paragraph~\ref{GenDoc} below.\\
%
% \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.sty\\
%   thumbs.pdf & doc/latex/thumbs.pdf\\
%   thumbs-example.tex & doc/latex/thumbs-example.tex\\
%   thumbs-example.pdf & doc/latex/thumbs-example.pdf\\
%   thumbs.dtx & source/latex/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 (\teTeX, \mikTeX,\dots) relies on file name
% databases, you must refresh these. For example, \teTeX\ 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 this
% 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.drv
%makeindex -s gind.ist thumbs.idx
%pdflatex thumbs.drv
%makeindex -s gind.ist thumbs.idx
%pdflatex thumbs.drv
%\end{verbatim}
% \end{quote}
%
% \subsection{Compiling the example}
%
% The example file, \textsf{thumbs-example.tex}, can be compiled via\\
% \indent |latex thumbs-example.tex|\\
% or (recommended)\\
% \indent |pdflatex thumbs-example.tex|\\
% and will need probably at least four~(!) compiler runs to get everything right.
%
% \bigskip
%
% \section{Acknowledgements}
%
% I would like to thank \textsc{Heiko Oberdiek}
% (heiko dot oberdiek at googlemail dot com) 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 the \Newsgroup{comp.text.tex} and \Newsgroup{de.comp.text.tex}
% newsgroups for their help in all things \TeX.
%
% \bigskip
%
% \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{http://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^ \textrm{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,
%             and the document was compiled again, and the \xfile{.aux} file was
%             reused, then reading from the then empty \xfile{.tmb} files resulted
%             in an endless loop. Fixed.
%     \item Minor details.
%   \end{Version}
% \pagebreak
%   \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\\
%             |************** THUMB dimensions **************|\\
%             in the \xfile{log} file.
%     \item Bug fix: There was a\\
%             |  \advance\th@mbheighty-\th@mbsdistance|,\\
%             where\\
%             |  \advance\th@mbheighty-\th@mbsdistance|\\
%             |  \advance\th@mbheighty-\th@mbsdistance|\\
%             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, removed.
%     \item The \xpackage{infwarerr} package is used for its |\@PackageInfoNoLine| command.
%     \item The \xpackage{warning} package is no longer used, removed. Instead,
%             the \xpackage{atveryend} package is used, because it is loaded anyway
%             when \xpackage{hyperref} is used.
%     \item Minor details.
%   \end{Version}
% \end{History}
%
% \bigskip
%
% 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.)\\
%
% Note: \textsf{Q}, \textsf{X}, and \textsf{Y} are not missing in the following index,
% but no command \emph{beginning} with any of these letters has been used in this
% \xpackage{thumbs} package.
%
% \pagebreak
%
% \PrintIndex
%
% \Finale
\endinput