Changes

Jump to navigation Jump to search
1,546 bytes added ,  20:28, 23 March 2013
special background: Hans' example on the mailing list
\chapter{Here we go!}
\stoptext
</context>
 
===Title page with special background===
 
If you want the title page of every chapter to have a special background (different from the background of normal pages), here's a very effective trick that Hans has provided on the mailing list. In addition, this will give every chapter its own color scheme (Mkiv only, hence won't compile on contextgarden):
 
<context source=yes>
\startMPinclusions
numeric MyTitlePageDone[] ;
\stopMPinclusions
 
\startuseMPgraphic{background:normal}
StartPage ;
fill (topboundary Page -- cycle) enlarged(0,5mm)
shifted (0,-5mm) withcolor blue ;
StopPage ;
\stopuseMPgraphic
 
\defineoverlay
[background:normal]
[\useMPgraphic{background:normal}]
 
\startuseMPgraphic{background:title}
if unknown MyTitlePageDone.\namedstructureuservariable{chapter}{mycolor} :
StartPage ;
fill ((topboundary Page --cycle) enlarged(0,5mm)) shifted (0,-20mm)
withcolor \MPcolor{color:title:namedstructureuservariable{chapter}mycolor}} ;
StopPage ;
MyTitlePageDone.\namedstructureuservariable{chapter}{mycolor} := 1 ;
fi ;
\stopuseMPgraphic
 
\defineoverlay
[background:title]
[\useMPgraphic{background:title}]
 
\setupbackgrounds
[page]
[background={background:normal,background:title}]
 
\definecolor [color:title:one] [red]
\definecolor [color:title:two] [blue]
 
\starttext
 
\startchapter[title=One][mycolor=one] \input tufte \page \input knuth \stopchapter
\startchapter[title=Two][mycolor=two] \input tufte \page \input knuth \stopchapter
 
\stoptext
 
</context>
gardener
111

edits

Navigation menu