Changes

Jump to navigation Jump to search
1,138 bytes removed ,  08:39, 20 July 2022
remove todo template
{{todo | this page needs to be cleaned up}}
The following code is an example of how to draw a graphic on every page of a document. The graphic (a grey rectangle) appears in a different place for each chapter, and the chapter number appears in the rectangle as well. This is often called a thumb index - your thumb can flip the pages of a book while you watch the contents flash past...
<texcode>
% by Hans Hagen, of course :-)
<context source="yes">% these first lines are just for wiki layout and visualisation\unprotected setuppapersize[A8][A5,landscape] \defshowframe\rawsectionnumber#1{setuppaper[nx=4,ny=2]\countervalue{setuparranging[XY]\??se#1}} % will be in kernelusemodule[visual]
\setuppagenumbering [alternative=doublesided] \setupcolors [state=start] \setupbackgrounds [page] [background=thumbs] def\defineoverlaycurrentchapternumber [thumbs] [\setups{thumbs}] \def\NOfChapterssomenamedheadnumber{4chapter} % i need to make this one available \startsetups thumbs  \definemeasure[thumbheight][\dimexpr\paperheight/\NOfChapters\relax]  \vbox to \paperheight \bgroup \vskip \rawsectionnumber{section-2} \measure{thumbheightcurrent} \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 def\chapter{first} \dorecurse{10}{\input tufte }lastchapternumber\chapter {second} \dorecurse{10}somenamedheadnumber{\input davis }\chapter{third} \dorecurse{10}{\input zapf }\chapter{fourth} \dorecurse{10}{\input bryson } \stoptext</texcode>  <context>% by Hans Hagen, of course :-) \unprotected \def\rawsectionnumber#1{\countervalue{\??se#1last}} % will be in kernel
\setuppagenumbering
[alternative=doublesided]
 
\setupcolors
[state=start]
\setupbackgrounds
[\setups{thumbs}]
\defnewdimen\NOfChapters{4} % i need to make this one availablethumbheight
\startsetups thumbs
\ifnum \lastchapternumber > 0 \definemeasure[thumbheight][=\dimexpr\paperheight/\NOfChapterslastchapternumber\relax] \fi
\vbox to \paperheight \bgroup
\vskip \rawsectionnumber{section-2} currentchapternumber \measure{thumbheight} \vskip -1 \measure{thumbheight}
\doifoddpageelse\hfill\donothing
\framed
[background=color,
backgroundcolor=darkgrayblue,
frame=off,
foregroundcolor=white,
height=\measure{thumbheight}, width=1cm5mm] {\bfa \rawsectionnumber{section-2}currentchapternumber}
\doifoddpageelse\donothing\hfill
\vss
\starttext
\chapterdorecurse{first4} \dorecurse{10}{\input tufte }\chapter{second} \dorecursefakewords{101}{\input davis 5}}\chapter{third} \dorecurse{10}{\input zapf }\chapterfakewords{fourth50} \dorecurse{10100}{\input bryson }
\stoptext
An example (MkIV) for using Metapost to create thumb indices for chapters.
<texcodecontext source="yes">% these first lines are just for wiki layout and visualisation\setuppapersize[A8][A4]\showframe\setuppaper[A4nx=4,oversizedny=4]\setuparranging[XY]\usemodule[visual]
\setuplayout
\starttext \showframe
\dorecurse{63}{\chapter{Test Chapter #1}
Chapter \someheadnumber[chapter][current] of
\someheadnumber[chapter][last]
Section \someheadnumber[section][current] of
\someheadnumber[section][last] \blank
\input tufte \par \input knuth fakewords{10}{20} \par
}
}
\stoptext
</texcodecontext>
[[Category:Sample documents]]
[[Category:Graphics]]

Navigation menu