Changes

Jump to navigation Jump to search
1,974 bytes added ,  07:47, 22 January 2010
Merging the contents of Chapter thumbs with metapost
\chapter{fourth} \dorecurse{10}{\input bryson }
\stoptext
</texcode>
 
 
== Another Example ==
An example (MkIV) for using Metapost to create thumb indices for chapters.
 
<texcode>
\setuppapersize[A4][A4,oversized]
 
\setuplayout
[width=middle,
% margin=\dimexpr\backspace-\margindistance\relax
location=middle]
 
\definecolor[chap_frame][g=1,t=1,a=12]
\definecolor[sect_frame][b=1,t=1,a=12]
\definecolor[textcolor] [r=1,t=1,a=12]
 
\startuseMPgraphic{chapter thumb}
path chap_frame, sect_frame ; pair pos,a,b ; picture text ;
curr_chap := \somenamedheadnumber{chapter}{current} ;
last_chap := \somenamedheadnumber{chapter}{last} ;
curr_sect := \somenamedheadnumber{section}{current} ;
last_sect := \somenamedheadnumber{section}{last} ;
 
skip := TextHeight * (curr_chap-1)/last_chap ;
height := TextHeight/last_chap ;
sskip := height*curr_sect/last_sect ;
text := textext("\ssbfb\textcolor Chapter\enspace\getmarking[chapternumber]");
 
StartPage ;
chap_frame := fullsquare xyscaled(RightMarginWidth,height) ;
 
a := ulcorner chap_frame ;
b := urcorner chap_frame ;
 
sect_frame := a--b--(xpart b,ypart b-sskip)--(xpart a,ypart a-sskip)--cycle;
 
pos := urcorner Field[Text][RightMarginSeparator] -
ulcorner chap_frame - (0,skip);
 
fill chap_frame shifted pos withcolor \MPcolor{chap_frame};
unfill sect_frame shifted pos withcolor white ;
fill sect_frame shifted pos withcolor \MPcolor{sect_frame};
draw text rotated 90 shifted pos ;
StopPage ;
\stopuseMPgraphic
 
 
\defineoverlay[chapter thumb][\useMPgraphic{chapter thumb}]
 
\setupbackgrounds[page][background=chapter thumb]
 
 
\starttext \showframe
\dorecurse{6}{\chapter{Test Chapter #1}
Chapter \somestructureheadnumber[chapter][current] of
\somestructureheadnumber[chapter][last]
\dorecurse{9}{\section{Test Section}
Section \somestructureheadnumber[section][current] of
\somestructureheadnumber[section][last] \blank
\input tufte \par \input knuth \par
}
}
\stoptext
</texcode>

Navigation menu