I guess what you want are chapter thumbs or a thumb index. Here’s a nearly automatic solution using TikZ:
\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 to set the number of thumbs fitting vertical
% and setting the height of a boxes
\newcounter{letterdiv}
\setcounter{letterdiv}{4}
% some margin settings
\newlength{\thumbtopmargin}
\setlength{\thumbtopmargin}{2cm}
\newlength{\thumbbottommargin}
\setlength{\thumbbottommargin}{2cm}
% calculate the box height by dividing the page height
\newlength{\thumbheight}
\pgfmathsetlength{\thumbheight}{%
(\paperheight-\thumbtopmargin-\thumbbottommargin)%
/%
\value{letterdiv}
}
% box width
\newlength{\thumbwidth}
\setlength{\thumbwidth}{1cm}
% style the boxes
\tikzset{
thumb/.style={
fill=black!50!red,
text=white,
minimum height=\thumbheight,
text width=\thumbwidth,
outer sep=0pt,
font=\sffamily\bfseries\Huge,
inner xsep=1.5em,
}
}
% create two new commands to make the thumbs
% that makes it easy to use them im different header elements,
% like in the plain and normal page style etc.
\newcommand{\evenpageletterthumb}[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}-1)*\thumbheight})%
$) {#1};
\end{tikzpicture}
}
\newcommand{\oddpageletterthumb}[1]{%
\begin{tikzpicture}[remember picture, overlay]
\node [thumb,align=right,anchor=north east,] at ($%
(current page.north east)-%
(0,{\thumbtopmargin+(\value{letternum}-1)*\thumbheight})%
$) {#1};
\end{tikzpicture}
}
% create a new command to set a new lettergroup
\newcommand{\lettergroup}[1]{%
% but I recommend to start a new page
\clearpage
% set a title (optional)
{\Huge\bfseries\sffamily #1}\par\bigskip
% check if we reached the last vertical position and reset it
\ifnum\value{letternum}=\value{letterdiv}\relax
\setcounter{letternum}{0}%
\fi
% check if we reached the last vertical position and reset it
\ifnum\value{letternum}=\value{letterdiv}\relax
\setcounter{letternum}{0}%
\fi
\stepcounter{letternum}%
% 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[\oddpageletterthumb{#1}]{\oddpageletterthumb{#1}}%
\lehead[\evenpageletterthumb{#1}]{\evenpageletterthumb{#1}}%
}
% for some blindtext
\usepackage{lipsum}
\begin{document}
% usage: \lettergroup{<letter>}
% e.g.
\lettergroup{A}
% your text
\lipsum[1]
\lettergroup{B}
\lipsum[1]
\lettergroup{C}
\lipsum[1]
\lettergroup{D}
\lipsum[1]
\lettergroup{E}
\lipsum[1]
\lettergroup{F}
\lipsum[1]
\lettergroup{G}
\lipsum[1]
\end{document}
Update
I made an update so it is now possible to set how many letter thumbs should fit in the margin before the next letter group starts from the to again. Thats better for a high number of group where the box height will be very small otherwise. I renamed lettersum
by letterdiv
so the name matches the function.
The counter letterdiv
is used to set the number of boxes fitting in the page height. I set it to 4
in my example to show how it works. As you can see the fifth letter E
is printed at the first position form to again.
Best Answer
Another solution with only KOMA-Script tools (and some low level trickery):
I use the normal footer, putting into it a zero height box that contains a zero width box that is raised to the center of the text block; in it the page number is typeset shifted on the right or on the left depending if we are in an odd or even page.