-
Notifications
You must be signed in to change notification settings - Fork 1
/
chapterthumb.sty
93 lines (93 loc) · 2.99 KB
/
chapterthumb.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
% 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}%
[2014/01/15 v0.3 unsupported LaTeX package]
\ProcessOptions\relax
\RequirePackage{graphicx,color}
\RequirePackage{scrlayer}
\newcommand*{\firstchapterthumbskip}{.18\paperheight}
\newcommand*{\horizontalthumbskip}{2.3cm}
\newcommand*{\lastchapterthumbskip}{0pt}
\newcommand*{\chapterthumbheight}{3em}
\newcommand*{\chapterthumbwidth}{.1\paperheight}
\newcommand*{\chapterthumbskip}{.1\paperheight}
\newcommand*{\chapterthumbboxcolor}{black}
\newcommand*{\chapterthumbcolor}{white}
\newcommand*{\chapterthumbformat}{\@chapapp~\thechapter}
\newkomafont{chapterthumb}{\normalfont\normalsize\sffamily}
\newcommand*{\chapterthumbbox}{%
\if@mainmatter
\ifnum\value{chapter}>\z@
\ifnum \value{chapterthumb}<\z@
\else
\begingroup
\edef\reserved@a{\chapterthumbformat}%
\ifx\reserved@a\lastthechapter\else
\stepcounter{chapterthumb}%
\global\let\lastthechapter\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[\horizontalthumbskip][r]{%
\rotatebox[origin=tl]{90}{%
\setlength{\fboxsep}{0pt}% default: 0pt, increase to get taller box
\colorbox{\chapterthumbboxcolor}{%
\parbox[c][\chapterthumbheight][c]%
{\chapterthumbwidth}{%
\centering
\color{\chapterthumbcolor}%
\usekomafont{chapterthumb}{%
\chapterthumbformat\vspace{2mm}
}}}}}%
\endgroup
\fi
\fi
\fi
}
\newcounter{chapterthumb}
\setcounter{chapterthumb}{10000}
\newcommand*{\lastthechapter}{\relax}
\DeclareNewLayer[%
background,%
oddpage,%
rightmargin,%
contents=\chapterthumbbox
]{chapterthumb}
\endinput