From 287d865990e5823a75263a98624f9f4bd89192a4 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sun, 9 Mar 2014 21:30:19 +0000
Subject: thumbs (9mar14)

git-svn-id: svn://tug.org/texlive/trunk@33134 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/thumbs/thumbs.sty | 376 +++++++++++++++++++-------
 1 file changed, 271 insertions(+), 105 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/thumbs/thumbs.sty')

diff --git a/Master/texmf-dist/tex/latex/thumbs/thumbs.sty b/Master/texmf-dist/tex/latex/thumbs/thumbs.sty
index 7b7f5678145..537e8409025 100644
--- a/Master/texmf-dist/tex/latex/thumbs/thumbs.sty
+++ b/Master/texmf-dist/tex/latex/thumbs/thumbs.sty
@@ -9,9 +9,9 @@
 %% This is a generated file.
 %% 
 %% Project: thumbs
-%% Version: 2012/02/25 v1.0n
+%% Version: 2014/03/09 v1.0q
 %% 
-%% Copyright (C) 2010 - 2012 by
+%% Copyright (C) 2010 - 2014 by
 %%     H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
 %% 
 %% The usual disclaimer applies:
@@ -35,62 +35,49 @@
 %% 
 %% This work consists of the main source file thumbs.dtx,
 %% the README, and the derived files
-%%    thumbs.sty, thumbs.pdf, thumbs.ins, thumbs.drv,
+%%    thumbs.sty, thumbs.pdf,
+%%    thumbs.ins, thumbs.drv,
 %%    thumbs-example.tex, thumbs-example.pdf.
 %% 
+%% In memoriam Tommy Muench + 2014/01/02.
+%% 
 \NeedsTeXFormat{LaTeX2e}[2011/06/27]
-\ProvidesPackage{thumbs}[2012/02/25 v1.0n
+\ProvidesPackage{thumbs}[2014/03/09 v1.0q
             Thumb marks and overview page(s) (HMM)]
 
 %% This package allows to create a customizable thumb index,
 %% providing a quick and easy reference method for large documents,
 %% as well as an overview page.
 
-\IfFileExists{tcilatex.tex}{%
-  % Quite probably SWP/SW/SN
+\IfFileExists{tcilatex.tex}{% Quite probably SWP/SW/SN
   \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%
-   \string\providecommand{\string\QTO}[2]{\string##2}\MessageBreak%
-   especially before hyperref and thumbs,\MessageBreak%
-   but best right after the \string\documentclass!%
-   }%
-  }{% Probably not SWP/SW/SN
-   \message{^^J *** Compiling with SW(P)? ^^J%
-    When compiling with SWP 5.50 Build 2960^^J%
-    (copyright MacKichan Software, Inc.),^^J%
-    these additional packages are needed:^^J%
-    \string\usepackage[T1]{fontenc}^^J%
-    \string\usepackage{amsfonts}^^J%
-    \string\usepackage[math]{cellspace}^^J%
-    \string\usepackage{xcolor}^^J%
-    \string\pagecolor{white}^^J%
-    \string\providecommand{\string\QTO}[2]{\string##2}^^J%
-    especially before hyperref and thumbs,^^J%
-    but best right after the \string\documentclass!^^J%
-    ^^J%
+    When compiling with SWP 5.50 Build 2960\MessageBreak%
+    (copyright MacKichan Software, Inc.)\MessageBreak%
+    and using an older version of the thumbs package\MessageBreak%
+    these additional packages were needed:\MessageBreak%
+    \string\usepackage[T1]{fontenc}\MessageBreak%
+    \string\usepackage{amsfonts}\MessageBreak%
+    \string\usepackage[math]{cellspace}\MessageBreak%
+    \string\usepackage{xcolor}\MessageBreak%
+    \string\pagecolor{white}\MessageBreak%
+    \string\providecommand{\string\QTO}[2]{\string##2}\MessageBreak%
+    especially before hyperref and thumbs,\MessageBreak%
+    but best right after the \string\documentclass!%
     }%
-   }
+  }{% Probably not SWP/SW/SN
+  }
 
-\RequirePackage{kvoptions}[2010/12/23]%      v3.10
-\RequirePackage{atbegshi}[2011/01/30]%       v1.15
+\RequirePackage{kvoptions}[2011/06/30]%      v3.11
+\RequirePackage{atbegshi}[2011/10/05]%       v1.16
 \RequirePackage{xcolor}[2007/01/21]%         v2.11
 \RequirePackage{picture}[2009/10/11]%        v1.3
-\RequirePackage{alphalph}[2010/04/18]%       v2.3
-\RequirePackage{pageslts}[2011/08/08]%       v1.2a
+\RequirePackage{alphalph}[2011/05/13]%       v2.4
+\RequirePackage{pageslts}[2014/01/19]%       v1.2c
 \RequirePackage{pagecolor}[2012/02/23]%      v1.0e
 \RequirePackage{rerunfilecheck}[2011/04/15]% v1.7
 \RequirePackage{infwarerr}[2010/04/08]%      v1.3
-\RequirePackage{ltxcmds}[2011/04/18]%        v1.20
-\RequirePackage{atveryend}[2011/04/23]%      v1.7
-%% \RequirePackage{atveryend}[2011/06/30]%   v1.8
-%% would be needed but is currently (2012/02/25) not available at CTAN yet.
+\RequirePackage{ltxcmds}[2011/11/09]%        v1.22
+\RequirePackage{atveryend}[2011/06/30]%      v1.8
 %% thumbs may work with earlier versions of LaTeX2e and those packages,
 %% but this was not tested. Please consider updating your LaTeX contribution
 %% and packages to the most recent version (if they are not already the most
@@ -100,13 +87,13 @@
 {\@ifpackagelater{atveryend}{2011/06/29}%
  {% 2011/06/30, v1.8, or even more recent: OK
  }{% else: older package version, no \AtVeryVeryEnd
-   \PackageWarningNoLine{thumbs}{%
+   \PackageError{thumbs}{Outdated atveryend package version}{%
      LaTeX 2011/06/27 has changed \string\enddocument\space and thus broken the\MessageBreak%
      \string\AtVeryVeryEnd\space command/hooking of atveryend package as of\MessageBreak%
-     2011/04/23, v1.7. New package version 2011/06/30, v1.8, works with\MessageBreak%
+     2011/04/23, v1.7. Package versions 2011/06/30, v1.8, and later work with\MessageBreak%
      the new LaTeX format, but some older package version was loaded.\MessageBreak%
-     (As of 2012/02/25, the new version is NOT available at CTAN yet.)\MessageBreak%
-     For fixing this problem until the update is available,\MessageBreak%
+     Please update to the newer atveryend package.\MessageBreak%
+     For fixing this problem until the updated package is installed,\MessageBreak%
      \string\let\string\AtVeryVeryEnd\string\AtEndAfterFileList\MessageBreak%
      is used now, fingers crossed.%
      }%
@@ -127,6 +114,12 @@
 \DeclareStringOption{distance}[2mm]
 \DeclareStringOption{topthumbmargin}[auto]
 \DeclareStringOption{bottomthumbmargin}[auto]
+\DeclareStringOption[5pt]{eventxtindent}[5pt]
+\DeclareStringOption[5pt]{oddtxtexdent}[5pt]
+\DeclareStringOption[0pt]{evenmarkindent}[0pt]
+\DeclareStringOption[0pt]{oddmarkexdent}[0pt]
+\DeclareStringOption[0pt]{evenprintvoffset}[0pt]
+\DeclareBoolOption[false]{txtcentered}
 \DeclareBoolOption[true]{ignorehoffset}
 \DeclareBoolOption[true]{ignorevoffset}
 \DeclareBoolOption{nophantomsection}% false by default, but true if used
@@ -135,14 +128,17 @@
 \DeclareBoolOption{draft}
 \DeclareComplementaryOption{final}{draft}
 \DeclareBoolOption[false]{hidethumbs}
+%% Obsolete options:
 \DeclareStringOption{pagecolor}
+\DeclareStringOption{evenindent}
+\DeclareStringOption{oddexdent}
 
 \ProcessKeyvalOptions*
 
-\ifx\thumbs@pagecolor\empty%
+\ifx\thumbs@pagecolor\empty\relax
   \pagecolor{\thepagecolor}
 \else
-  \PackageWarningNoLine{thumbs}{Option pagecolor is obsolete.\MessageBreak%
+  \PackageError{thumbs}{Option pagecolor is obsolete}{%
     Instead the pagecolor package is used.\MessageBreak%
     Use \string\pagecolor{...}\space after \string\usepackage[...]{thumbs}\space and\MessageBreak%
     before \string\begin{document}\space to define a background colour\MessageBreak%
@@ -150,6 +146,22 @@
   \pagecolor{\thumbs@pagecolor}
 \fi
 
+\ifx\thumbs@evenindent\empty\relax
+\else
+  \PackageError{thumbs}{Option evenindent is obsolete}{%
+    Option "evenindent" was renamed to "eventxtindent",\MessageBreak%
+    the obsolete "evenindent" is no longer regarded.\MessageBreak%
+    Please change your document accordingly}
+\fi
+
+\ifx\thumbs@oddexdent\empty\relax
+\else
+  \PackageError{thumbs}{Option oddexdent is obsolete}{%
+    Option "oddexdent" was renamed to "oddtxtexdent",\MessageBreak%
+    the obsolete "oddexdent" is no longer regarded.\MessageBreak%
+    Please change your document accordingly}
+\fi
+
 \ifthumbs@ignorehoffset
   \PackageInfo{thumbs}{%
     Option ignorehoffset NOT =false:\MessageBreak%
@@ -192,9 +204,9 @@
       \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%
+        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
@@ -209,13 +221,25 @@
 \newdimen\th@mbposx
 \newdimen\th@mbposy
 \newdimen\th@mbposyA
+\newdimen\th@mbposyB
 \newdimen\th@mbposytop
 \newdimen\th@mbposybottom
 \newdimen\th@mbwidthxtoc
+\newdimen\th@mbwidthtmp
 \newdimen\th@mbsposytocy
 \newdimen\th@mbsposytocyy
 
-\newdimen\th@mbsdistance% vertical distance between thumb marks
+\newdimen\th@mbHitO
+\setlength{\th@mbHitO}{\thumbs@oddtxtexdent}
+\newdimen\th@mbHitE
+\setlength{\th@mbHitE}{\thumbs@eventxtindent}
+
+\newdimen\th@mbHimO
+\setlength{\th@mbHimO}{\thumbs@oddmarkexdent}
+\newdimen\th@mbHimE
+\setlength{\th@mbHimE}{\thumbs@evenmarkindent}
+
+\newdimen\th@mbsdistance
 \ifx\thumbs@distance\empty%
   \setlength{\th@mbsdistance}{1mm}
 \else
@@ -274,6 +298,25 @@
    }
 \fi
 
+\newcommand{\th@mb@txtBox}[4]{%
+  \parbox[c][\th@mbheighty][c]{#4}{%
+    \settowidth{\th@mbwidthtmp}{\normalsize #2}%
+    \addtolength{\th@mbwidthtmp}{-#4}%
+    \ifthumbs@txtcentered%
+      {\centering{\color{#1}\normalsize #2}}%
+    \else%
+      \def\th@mbstest{#3}%
+      \def\th@mbstestb{r}%
+      \ifx\th@mbstest\th@mbstestb%
+         \ifdim\th@mbwidthtmp >0sp\relax\hspace*{-\th@mbwidthtmp}\fi%
+         {\raggedleft\leftskip 0sp minus \textwidth{\hfill\color{#1}\normalsize{#2}}}%
+      \else% \th@mbstest = l
+        {\raggedright{\color{#1}\normalsize\hspace*{1pt}\space{#2}}}%
+      \fi%
+    \fi%
+    }%
+  }
+
 \newcommand{\setth@mbheight}{%
   \setlength{\th@mbheighty}{\z@}
   \advance\th@mbheighty+\headheight
@@ -309,11 +352,12 @@
       \ifdim \thumbs@minheight > \@tempdima% 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%
+          As value for option minheight please use\MessageBreak%
+          a number and a length unit (e.g. mm, cm, pt)\MessageBreak%
+          and no space between them\MessageBreak%
           and include this value+unit combination in curly brackets\MessageBreak%
           (please see the thumbs-example.tex file).\MessageBreak%
-          When pressing return, minheight will now be set to 47pt.\MessageBreak%
+          When pressing Return, minheight will now be set to 47pt.\MessageBreak%
          }
         \setlength{\thumbs@minheight}{47pt}
       \fi
@@ -328,12 +372,12 @@
       \setth@mbheight
       \ifdim \th@mbheighty < \thumbs@minheight
         \PackageWarningNoLine{thumbs}{Thumbs not high enough:\MessageBreak%
-          Option height has value 'auto'. For \th@mbsmax\space thumbs per page\MessageBreak%
+          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'%
+          for option "minheight"%
         }
         \setlength{\th@mbheighty}{\z@}
         \advance\th@mbheighty by \@tempdima% = \thumbs@minheight
@@ -358,7 +402,7 @@
   \else
     \setlength{\th@mbwidthx}{\paperwidth}
     \advance\th@mbwidthx-\textwidth
-    \divide\th@mbwidthx4
+    \divide\th@mbwidthx by 4
     \setlength{\@tempdima}{0sp}
     \ifx\thumbs@width\empty%
     \else
@@ -390,7 +434,7 @@
             \setlength{\th@mbwidthx}{\thumbs@width}
           \else
             \PackageError{thumbs}{Thumbs not wide enough}{%
-              Option width has value '\thumbs@width'.\MessageBreak%
+              Option width has value "\thumbs@width".\MessageBreak%
               This is not a valid dimension larger than zero.\MessageBreak%
               Width will be set automatically.\MessageBreak%
              }
@@ -429,7 +473,7 @@
     \ifdim \thumbs@topthumbmargin > \@tempdima% OK
     \else
       \PackageWarning{thumbs}{Thumbs column starting too high.\MessageBreak%
-        Option topthumbmargin has value '\thumbs@topthumbmargin'.\MessageBreak%
+        Option topthumbmargin has value "\thumbs@topthumbmargin ".\MessageBreak%
         topthumbmargin will be set to -1pt.\MessageBreak%
        }
       \gdef\thumbs@topthumbmargin{-1pt}
@@ -481,8 +525,8 @@
       \advance\@tempdima by -\th@mbsdistance
       \advance\@tempdima by -1pt
       \PackageWarning{thumbs}{Thumbs column ending too high.\MessageBreak%
-        Option bottomthumbmargin has value '\thumbs@bottomthumbmargin'.\MessageBreak%
-        bottomthumbmargin will be set to '\the\@tempdima'.\MessageBreak%
+        Option bottomthumbmargin has value "\thumbs@bottomthumbmargin ".\MessageBreak%
+        bottomthumbmargin will be set to "\the\@tempdima".\MessageBreak%
        }
       \xdef\thumbs@bottomthumbmargin{\the\@tempdima}
     \fi
@@ -490,7 +534,7 @@
     \setlength{\@tempdimc}{-1pt}
     \ifdim \@tempdima < \@tempdimc%
       \PackageWarning{thumbs}{Thumbs column ending too low.\MessageBreak%
-        Option bottomthumbmargin has value '\thumbs@bottomthumbmargin'.\MessageBreak%
+        Option bottomthumbmargin has value "\thumbs@bottomthumbmargin ".\MessageBreak%
         bottomthumbmargin will be set to -1pt.\MessageBreak%
        }
       \gdef\thumbs@bottomthumbmargin{-1pt}
@@ -559,9 +603,7 @@
 
 \gdef\th@mbsphantom{1}
 
-\newcommand{\thumbsnophantom}{%
-  \gdef\th@mbsphantom{0}%
-  }
+\newcommand{\thumbsnophantom}{\gdef\th@mbsphantom{0}}
 
 \newcommand{\addthumb}[4]{%
   \gdef\th@mbprinting{1}%
@@ -585,7 +627,12 @@
   \gdef\th@mbtext{#2}%
   \gdef\th@mbtextcolour{#3}%
   \gdef\th@mbbackgroundcolour{#4}%
-  \settowidth{\@tempdima}{\th@mbtext\space}%
+  \settowidth{\@tempdima}{\th@mbtext}%
+  \ifdim\th@mbHitO>\th@mbHitE\relax%
+    \advance\@tempdima+\th@mbHitO%
+  \else%
+    \advance\@tempdima+\th@mbHitE%
+  \fi%
   \ifdim\@tempdima>\th@mbmaxwidth%
     \xdef\th@mbmaxwidth{\the\@tempdima}%
   \fi%
@@ -703,24 +750,52 @@
   \advance\th@mbwidthxtoc-1in%
   \def\th@mbstest{r}%
   \ifx\th@mbstest\th@mbsprintpage% r
+    \advance\th@mbwidthxtoc-\th@mbHimO%
     \advance\th@mbwidthxtoc-\oddsidemargin%
     \setlength{\@tempdimc}{1in}%
     \advance\@tempdimc+\oddsidemargin%
   \else% l
+    \advance\th@mbwidthxtoc-\th@mbHimE%
     \advance\th@mbwidthxtoc-\evensidemargin%
     \setlength{\@tempdimc}{\th@bmshoffset}%
     \advance\@tempdimc-\hoffset
   \fi%
-  \put(\@tempdimc,-\th@mbposy){%
-    \def\th@mbstest{l}%
+  \setlength{\th@mbposyB}{-\th@mbposy}%
+  \if@twoside%
+    \ifodd\c@CurrentPage%
+      \ifx\th@mbtikz\pagesLTS@zero%
+      \else%
+        \setlength{\@tempdimb}{-\th@mbposy}%
+        \advance\@tempdimb-\thumbs@evenprintvoffset%
+        \setlength{\th@mbposyB}{\@tempdimb}%
+      \fi%
+    \else%
+      \ifx\th@mbtikz\pagesLTS@zero%
+        \setlength{\@tempdimb}{-\th@mbposy}%
+        \advance\@tempdimb-\thumbs@evenprintvoffset%
+        \setlength{\th@mbposyB}{\@tempdimb}%
+      \fi%
+    \fi%
+  \fi%
+  \def\th@mbstest{l}%
+  \ifx\th@mbstest\th@mbsprintpage% l
+    \advance\@tempdimc+\th@mbHimE%
+  \fi%
+  \put(\@tempdimc,\th@mbposyB){%
     \ifx\th@mbstest\th@mbsprintpage% l
-      \advance\th@mbwidthxtoc+\evensidemargin%
+      \ifdim\evensidemargin <0sp\relax%
+        \advance\th@mbwidthxtoc-\evensidemargin%
+      \else% >=0sp
+        \advance\th@mbwidthxtoc+\evensidemargin%
+      \fi%
     \fi%
     \begin{picture}(0,0)%
       \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}}}%
+         {\color{\th@mb@tmp@backgroundcolour}%
+          \hyperref[\th@mb@tmp@label]{\rule{\th@mbwidthxtoc}{\th@mbheighty}}%
+         }%
         \else%
           {\color{\th@mb@tmp@backgroundcolour}\rule{\th@mbwidthxtoc}{\th@mbheighty}}%
         \fi%
@@ -746,10 +821,40 @@
         \setlength{\th@mbwidthxtoc}{\textwidth}%
       \fi%
       \ifx\th@mbstest\th@mbsprintpage% l
-        \begin{picture}(0,0)(-6pt,-0.5\th@mbheighty+384930sp)%
+        \begin{picture}(-\th@mbHimE,0)(-6pt,-0.5\th@mbheighty+384930sp)%
           \bgroup%
             \setlength{\parindent}{0pt}%
-            \makebox[\th@mbwidthx][l]{{\color{\th@mb@tmp@textcolour}\th@mb@tmp@text}}%
+            \setlength{\@tempdimc}{\th@mbwidthx}%
+            \advance\@tempdimc-\th@mbHitO%
+            \setlength{\@tempdimb}{\th@mbwidthx}%
+            \advance\@tempdimb-\th@mbHitE%
+            \ifodd\c@CurrentPage%
+              \if@twoside%
+                \ifx\th@mbtikz\pagesLTS@zero%
+                  \hspace*{-\th@mbHitO}%
+                  \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
+                \else%
+                  \hspace*{+\th@mbHitE}%
+                  \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{l}{\@tempdimb}%
+                \fi%
+              \else%
+                \hspace*{-\th@mbHitO}%
+                \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
+              \fi%
+            \else%
+              \if@twoside%
+                \ifx\th@mbtikz\pagesLTS@zero%
+                  \hspace*{+\th@mbHitE}%
+                  \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{l}{\@tempdimb}%
+                \else%
+                  \hspace*{-\th@mbHitO}%
+                  \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
+                \fi%
+              \else%
+                \hspace*{-\th@mbHitO}%
+                \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
+              \fi%
+            \fi%
           \egroup%
         \end{picture}%
         \setlength{\@tempdimc}{-1in}%
@@ -809,7 +914,7 @@
                             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%
+                            Now setting it to "none" as last resort.\MessageBreak%
                            }%
                           \gdef\thumbs@thumblink{none}%
                           {\color{\th@mb@tmp@textcolour}\noindent%
@@ -831,7 +936,37 @@
         \begin{picture}(0,0)(1in+\oddsidemargin-\th@mbxpos+20pt,-0.5\th@mbheighty+384930sp)%
           \bgroup%
             \setlength{\parindent}{0pt}%
-            \makebox[\th@mbwidthx][r]{{\color{\th@mb@tmp@textcolour}\th@mb@tmp@text}}%
+            \setlength{\@tempdimc}{\th@mbwidthx}%
+            \advance\@tempdimc-\th@mbHitO%
+            \setlength{\@tempdimb}{\th@mbwidthx}%
+            \advance\@tempdimb-\th@mbHitE%
+            \ifodd\c@CurrentPage%
+              \if@twoside%
+                \ifx\th@mbtikz\pagesLTS@zero%
+                  \hspace*{-\th@mbHitO}%
+                  \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
+                \else%
+                  \hspace*{+\th@mbHitE}%
+                  \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{l}{\@tempdimb}%
+                \fi%
+              \else%
+                \hspace*{-\th@mbHitO}%
+                \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
+              \fi%
+            \else%
+              \if@twoside%
+                \ifx\th@mbtikz\pagesLTS@zero%
+                  \hspace*{+\th@mbHitE}%
+                  \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{l}{\@tempdimb}%
+                \else%
+                  \hspace*{-\th@mbHitO}%
+                  \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
+                \fi%
+              \else%
+                \hspace*{-\th@mbHitO}%
+                \th@mb@txtBox{\th@mb@tmp@textcolour}{\protect\th@mb@tmp@text}{r}{\@tempdimc}%
+              \fi%
+            \fi%
           \egroup%
         \end{picture}%
       \fi%
@@ -878,38 +1013,59 @@
   }
 
 \newcommand{\th@mbprint}[3]{%
-  \put(\th@mbxpos,-\th@mbposyA){%
+  \setlength{\th@mbposyB}{-\th@mbposyA}%
+  \if@twoside%
+    \ifodd\c@CurrentPage%
+      \ifx\th@mbtikz\pagesLTS@zero%
+      \else%
+        \setlength{\@tempdimc}{-\th@mbposyA}%
+        \advance\@tempdimc-\thumbs@evenprintvoffset%
+        \setlength{\th@mbposyB}{\@tempdimc}%
+      \fi%
+    \else%
+      \ifx\th@mbtikz\pagesLTS@zero%
+        \setlength{\@tempdimc}{-\th@mbposyA}%
+        \advance\@tempdimc-\thumbs@evenprintvoffset%
+        \setlength{\th@mbposyB}{\@tempdimc}%
+      \fi%
+    \fi%
+  \fi%
+  \put(\th@mbxpos,\th@mbposyB){%
     \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}%
+        \setlength{\@tempdimc}{\th@mbwidthx}%
+        \advance\@tempdimc-\th@mbHitO%
+        \setlength{\@tempdimb}{\th@mbwidthx}%
+        \advance\@tempdimb-\th@mbHitE%
         \ifodd\c@CurrentPage%
           \if@twoside%
             \ifx\th@mbtikz\pagesLTS@zero%
-             %\makebox[\th@mbwidthx][r]{{\color{#2}#1\space}}%
-              \parbox{\th@mbwidthx}{{\raggedleft{\hfill \color{#2}#1\space}}}%
+              \hspace*{-\th@mbHitO}%
+              \th@mb@txtBox{#2}{#1}{r}{\@tempdimc}%
             \else%
-             %\makebox[\th@mbwidthx][l]{{\color{#2}\hspace*{1pt}\space #1}}%
-              \parbox{\th@mbwidthx}{{\raggedright{\color{#2}\hspace*{1pt}\space #1}}}%
+              \hspace*{+\th@mbHitE}%
+              \th@mb@txtBox{#2}{#1}{l}{\@tempdimb}%
             \fi%
           \else%
-           %\makebox[\th@mbwidthx][r]{{\color{#2}#1\space}}%
-            \parbox{\th@mbwidthx}{{\raggedleft{\hfill \color{#2}#1\space}}}%
+            \hspace*{-\th@mbHitO}%
+            \th@mb@txtBox{#2}{#1}{r}{\@tempdimc}%
           \fi%
         \else%
           \if@twoside%
             \ifx\th@mbtikz\pagesLTS@zero%
-             %\makebox[\th@mbwidthx][l]{{\color{#2}\hspace*{1pt}\space #1}}%
-              \parbox{\th@mbwidthx}{{\raggedright{\color{#2}\hspace*{1pt}\space #1}}}%
+              \hspace*{+\th@mbHitE}%
+              \th@mb@txtBox{#2}{#1}{l}{\@tempdimb}%
             \else%
-             %\makebox[\th@mbwidthx][r]{{\color{#2}#1\space}}%
-              \parbox{\th@mbwidthx}{{\raggedleft{\hfill \color{#2}#1\space}}}%
+              \hspace*{-\th@mbHitO}%
+              \th@mb@txtBox{#2}{#1}{r}{\@tempdimc}%
             \fi%
           \else%
-           %\makebox[\th@mbwidthx][r]{{\color{#2}#1\space}}%
-            \parbox{\th@mbwidthx}{{\raggedleft{\hfill \color{#2}#1\space}}}%
+            \hspace*{-\th@mbHitO}%
+            \th@mb@txtBox{#2}{#1}{r}{\@tempdimc}%
           \fi%
         \fi%
       \egroup%
@@ -947,17 +1103,27 @@
     \advance\th@mbposx+1pt%
     \xdef\th@mbpaperwidth{\the\paperwidth}%
   \fi%
-  \def\th@mbxpos{\th@mbposx}%
+  \edef\th@mbxpos{\the\th@mbposx}%
   \ifodd\@tempcnta% \relax
   \else%
     \if@twoside%
       \ifthumbs@ignorehoffset%
-         \def\th@mbxpos{-1pt-\hoffset}%
+         \setlength{\@tempdimc}{-\hoffset}%
+         \advance\@tempdimc-1pt%
+         \edef\th@mbxpos{\the\@tempdimc}%
       \else%
         \def\th@mbxpos{-1pt}%
       \fi%
     \fi%
   \fi%
+  \setlength{\@tempdimc}{\th@mbxpos}%
+  \if@twoside%
+    \ifodd\@tempcnta \advance\@tempdimc-\th@mbHimO%
+    \else \advance\@tempdimc+\th@mbHimE%
+    \fi%
+  \else \advance\@tempdimc-\th@mbHimO%
+  \fi%
+  \edef\th@mbxpos{\the\@tempdimc}%
   \AtBeginShipoutUpperLeft{%
     \ifx\th@mbprinting\pagesLTS@one%
       \th@mbprint{\th@mbtextA}{\th@mbtextcolourA}{\th@mbbackgroundcolourA}%
@@ -1048,8 +1214,8 @@
   }
 
 \newcommand{\addthumbsoverviewtocontents}[2]{%
-  \gdef\th@mbs@toc@level{#1}
-  \gdef\th@mbs@toc@text{#2}
+  \gdef\th@mbs@toc@level{#1}%
+  \gdef\th@mbs@toc@text{#2}%
   }
 
 \newcommand{\clearotherdoublepage}{%
@@ -1102,8 +1268,8 @@
           \PackageError{thumbs}{%
              Invalid second parameter of \string\thumbsoverviewprint %
            }{The second argument of command \string\thumbsoverviewprint\space must be\MessageBreak%
-             either 'r' or 'l' or 'v' or 'd', but is 'X2'.\MessageBreak%
-             Now 'r' is chosen instead.\MessageBreak%
+             either "r" or "l" or "v" or "d" but it is neither.\MessageBreak%
+             Now "r" is chosen instead.\MessageBreak%
            }%
           \gdef\th@mbsprintpage{r}%
         \fi%
@@ -1130,10 +1296,10 @@
               \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%
+                  Option thumblink has invalid value "\thumbs@thumblink ".\MessageBreak%
+                  Valid values are "none", "title", "page",\MessageBreak%
+                  "titleandpage", "line", or "rule".\MessageBreak%
+                  "rule" will be used now.\MessageBreak%
                   }%
                 \gdef\thumbs@thumblink{rule}%
               \fi%
@@ -1142,11 +1308,11 @@
         \fi%
       \fi%
     }{% 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%
+      \PackageError{thumbs}{Option thumblink not "none", but hyperref not loaded}{%
+        The option thumblink of the thumbs package was not set to "none",\MessageBreak%
         but to some kind of hyperlinks, without using package hyperref.\MessageBreak%
-        Either choose option 'thumblink=none', or load package hyperref.\MessageBreak%
-        When pressing return, 'thumblink=none' will be set now.\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}%
      }%
@@ -1304,14 +1470,14 @@
                 \else% THIS SHOULD NEVER HAPPEN!
                   \PackageError{thumbs}{Unexpected error! (Really!)}{%
                     ! You are in trouble here.\MessageBreak%
-                    ! Type\space \space X \string<return\string>\space to quit.\MessageBreak%
+                    ! Type\space \space X \string<Return\string>\space to quit.\MessageBreak%
                     ! Delete temporary auxiliary files\MessageBreak%
                     ! (like \jobname.aux, \jobname.tmb, \jobname.out)\MessageBreak%
                     ! and retry the compilation.\MessageBreak%
                     ! If the error persists, cross your fingers\MessageBreak%
-                    ! and try typing\space \space \string<return\string>\space to proceed.\MessageBreak%
+                    ! and try typing\space \space \string<Return\string>\space to proceed.\MessageBreak%
                     ! If that does not work,\MessageBreak%
-                    ! you might contact the maintainer of the thumbs package.\MessageBreak%
+                    ! please contact the maintainer of the thumbs package.\MessageBreak%
                     }%
                 \fi%
               \fi%
@@ -1366,7 +1532,7 @@
   \renewcommand{\addthumb}[4]{\relax}
   \PackageWarningNoLine{thumbs}{thumbs package in hide mode:\MessageBreak%
     Thumb marks are hidden.\MessageBreak%
-    Remove package option hide to get thumb marks.\MessageBreak%
+    Set package option "hidethumbs=false" to get thumb marks%
    }
   \renewcommand{\thumbnewcolumn}{\relax}
 \fi
-- 
cgit v1.2.3

