Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %%% Source:
- %%% Tobi in http://tex.stackexchange.com/a/57317/9237
- %%% Some changes by Speravir
- %%%
- %%% Compare http://pastebin.com/hwu8c5QZ
- \documentclass{book}
- % load TikZ to draw the boxes
- \usepackage{tikz}
- \usetikzlibrary{calc}
- % use scrpage2 or whatever you want to add
- % the boxes to the header to make them appear
- % on every page
- \usepackage{scrpage2}
- \pagestyle{scrheadings}
- % new counter to hold the current number of the
- % letter to determine the vertical position
- \newcounter{letternum}
- % newcounter for the sum of all letters to get
- % the right height of a box
- \newcounter{lettersum}
- \setcounter{lettersum}{26}
- % some margin settings
- \newlength{\thumbtopmargin}
- \setlength{\thumbtopmargin}{1cm}
- \newlength{\thumbbottommargin}
- \setlength{\thumbbottommargin}{3cm}
- % calculate the box height by dividing the page height
- \newlength{\thumbheight}
- \pgfmathsetlength{\thumbheight}{%
- (\paperheight-\thumbtopmargin-\thumbbottommargin)%
- /%
- \value{lettersum}
- }
- % box width
- \newlength{\thumbwidth}
- \setlength{\thumbwidth}{1.5cm}
- % style the boxes
- \tikzset{
- thumb/.style={
- fill=black!50!red,
- text=white,
- minimum height=\thumbheight,
- text width=\thumbwidth,
- outer sep=0pt,
- font=\sffamily\bfseries,
- }
- }
- \newcommand{\oddthumb}[1]{%
- % see pgfmanual.pdf for more information about this part
- \begin{tikzpicture}[remember picture, overlay]
- \node [thumb,align=right,anchor=north east,] at ($%
- (current page.north east)-%
- (0,\thumbtopmargin+\value{letternum}*\thumbheight)%
- $) {#1};
- \end{tikzpicture}
- }
- \newcommand{\eventhumb}[1]{%
- % see pgfmanual.pdf for more information about this part
- \begin{tikzpicture}[remember picture, overlay]
- \node [thumb,align=left,anchor=north west,] at ($%
- (current page.north west)-%
- (0,\thumbtopmargin+\value{letternum}*\thumbheight)%
- $) {#1};
- \end{tikzpicture}
- }
- % create a new command to set a new lettergroup
- \newcommand{\lettergroup}[1]{%
- % add a chapter (optional)
- \chapter*{#1}%
- % \section*{#1}
- % use one head or foot element to put in the box
- % it doesn't matter which you use since the box
- % is positioned on the page absolutely
- \lohead[\oddthumb{#1}]{\oddthumb{#1}}%
- \rehead[\eventhumb{#1}]{\eventhumb{#1}}%
- % step the counter of the letters
- \stepcounter{letternum}%
- }
- % for some blindtext
- \usepackage{lipsum}
- \begin{document}
- % usage: \lettergroup{<letter>}
- % e.g.
- \lettergroup{A}
- % your text
- \lipsum[1-20]
- \lettergroup{B}
- \lipsum[21-40]
- \lettergroup{C}
- \lipsum[41-60]
- \lettergroup{D}
- \lipsum[61-80]
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement