-
Notifications
You must be signed in to change notification settings - Fork 2
/
sidspaltHack.sty
70 lines (59 loc) · 1.98 KB
/
sidspaltHack.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
%!TEX root = sidospalt.tex
\ProvidesPackage{sidspaltHack}
\RequirePackage{greekcount}
%\RequirePackage[T1]{fontenc}
\RequirePackage{everypage}
\RequirePackage{forloop,ifthen}
\RequirePackage{changepage}
\RequirePackage{tikz}
\RequirePackage[margin=0.3in]{geometry}
\usetikzlibrary{fit,calc}
% Vertical step between chapter marks
\newcommand\ystep{0.9cm}
% Y coordinate of current chapter label
\newcommand\y{-\value{ct}*\ystep}
% With of box around current chapter
\newcommand\w{1.3cm}
% Offset of the text with regards to the center of the box
\newcommand\dx{0.01cm}
\makeatletter
\newcommand\@song{1}
\newcommand\@chapter{1}
% Equivalent to nysida, but without newpage.
\newcommand\sidindex[2]{\renewcommand\@chapter{#1}\renewcommand\@song{#2}}
\newcommand\nysida[2]{\newpage\sidindex{#1}{#2}}
\newcommand\chaptertext[3][gray]{%
\draw[#1] (-\dx,\y) node {#2};
\draw[#1] (-\dx,\y-.3*\ystep) node {#3};
}
\newcommand\otherchapter[1][gray]{%
\chaptertext[#1]{\small{\greek{ct}}}{\small{\greekspelled{ct}}}%
}
\newcommand\thischapter{%
\fill[gray] (-\dx-.5*\w,\y+.4*\ystep) -- (.5*\w,\y+.4*\ystep) -- (.5*\w,\y-.6*\ystep) -- (-\dx-.5*\w,\y-.6*\ystep);
\chaptertext[white]{\small{\greek{ct}\@song}}{\small{\greekspelled{ct}}}
}
\newcommand\allchapters{%
\begin{tikzpicture}%
\forloop{ct}{1}{\value{ct}<17 and \value{ct}>0}{\ifthenelse{\@chapter=\value{ct}}{\thischapter}{ \otherchapter}}%
\end{tikzpicture}%
}
\newcommand\onlycurrentchapter{%
\begin{tikzpicture}%
\forloop{ct}{1}{\value{ct}<17 and \value{ct}>0}{\ifthenelse{\@chapter=\value{ct}}{\thischapter}{ \otherchapter[white]}}%
\end{tikzpicture}%
}
\newcounter{ct}
\AddEverypageHook{%
\checkoddpage%
\ifoddpage%
\begin{tikzpicture}[overlay, remember picture]%
\node[xshift=-.5*\w,yshift=-1in-.36\textheight] at (current page.north east) {\allchapters};%
\end{tikzpicture}%
\else
\begin{tikzpicture}[overlay, remember picture]%
\node[xshift=.50*\w,yshift=-1in-.35\textheight] at (current page.north west) {\onlycurrentchapter};%
\end{tikzpicture}%
\fi%
}
\makeatother