# [NTG-context] Thumb indexes

h h extern pragma at wxs.nl
Sun Feb 13 15:18:51 CET 2005

cormullion wrote:

> My last question! :-)  I would like to have the various ‘parts’ of a book marked with black rectangles at the right side of each page, visible when the reader flips through the pages. I googled successfully to find ‘fancyhdr’, but that’s a LaTeX package, so I don’t think it will work in ConTeXt. If it’s not too difficult in ConTeXt, can anyone share the secret?

you may only read this answer if you also put it in the wiki

\unprotected \def\rawsectionnumber#1{\countervalue{\??se#1}} % will be in kernel

\setuppagenumbering
[alternative=doublesided]

\setupcolors
[state=start]

\setupbackgrounds
[page]
[background=thumbs]

\defineoverlay
[thumbs]
[\setups{thumbs}]

\def\NOfChapters{4} % i need to make this one available

\startsetups thumbs

\definemeasure[thumbheight][\dimexpr\paperheight/\NOfChapters\relax]

\vbox to \paperheight \bgroup
\vskip \rawsectionnumber{section-2} \measure{thumbheight}
\vskip -1                           \measure{thumbheight}
\doifoddpageelse\hfill\donothing
\framed
[background=color,
backgroundcolor=darkgray,
frame=off,
foregroundcolor=white,
height=\measure{thumbheight},width=1cm]
{\bfa \rawsectionnumber{section-2}}
\doifoddpageelse\donothing\hfill
\vss
\egroup

\stopsetups

\starttext

\chapter{first}  \dorecurse{10}{\input tufte  }
\chapter{second} \dorecurse{10}{\input davis  }
\chapter{third}  \dorecurse{10}{\input zapf   }
\chapter{fourth} \dorecurse{10}{\input bryson }

\stoptext

-----------------------------------------------------------------