% chapterthumb.sty
% Copyright 2008 Markus Kohm
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%
http://www.latex-project.org/lppl.txt
% and version 1.3 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 Markus Kohm.
%
% This work consists of this file only.
%-----------------------------------------------------------------------
\ProvidesPackage{chapterthumb}%
[2016/02/01 v0.3a unsupported LaTeX package]
\ProcessOptions\relax
\RequirePackage{graphicx,color}
\RequirePackage{scrlayer}
\newcommand*{\firstchapterthumbskip}{.05\paperheight}
\newcommand*{\lastchapterthumbskip}{\firstchapterthumbskip}
\newcommand*{\chapterthumbheight}{2em}
\newcommand*{\chapterthumbwidth}{.2\paperheight}
\newcommand*{\chapterthumbskip}{.1\paperheight}
\newcommand*{\chapterthumbboxcolor}{black}
\newcommand*{\chapterthumbcolor}{white}
\newcommand*{\chapterthumbformat}{\@chapapp~\thechapter}
\newkomafont{chapterthumb}{\normalfont\Large\sffamily}
\newcommand*{\chapterthumbbox}{%
\if@mainmatter
\ifnum\value{chapter}>\z@
\ifnum \value{chapterthumb}<\z@
\else
\begingroup
\protected@edef\reserved@a{\chapterthumbformat}%
\ifx\reserved@a\lastchapterthumbformat\else
\stepcounter{chapterthumb}%
\global\let\lastchapterthumbformat\reserved@a
\fi
\@tempcnta=\numexpr
\dimexpr
\paperheight
-\firstchapterthumbskip
-\chapterthumbwidth
-\lastchapterthumbskip
\relax / \dimexpr
\chapterthumbskip
\relax
+1
\relax
\ifnum \value{chapterthumb}<\@tempcnta
\else
\setcounter{chapterthumb}{0}%
\fi
\vspace*{%
\dimexpr
\firstchapterthumbskip
+ ( \chapterthumbskip )
* \value{chapterthumb}%
- \baselineskip
\relax
}\par
\hfill
\makebox[0pt][r]{%
\rotatebox[origin=tl]{90}{%
\setlength{\fboxsep}{0pt}%
\colorbox{\chapterthumbboxcolor}{%
\parbox[c][\chapterthumbheight][c]%
{\chapterthumbwidth}{%
\centering
\color{\chapterthumbcolor}%
\usekomafont{chapterthumb}{%
\chapterthumbformat
}}}}}%
\endgroup
\fi
\fi
\fi
}
\newcounter{chapterthumb}
\setcounter{chapterthumb}{10000}
\newcommand*{\lastchapterthumbformat}{\relax}
\DeclareNewLayer[%
background,%
oddpage,%
rightmargin,%
contents=\chapterthumbbox
]{chapterthumb}
\endinput
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "chapterthumbexample"
%%% End: