Changes

Jump to navigation Jump to search
2,732 bytes added ,  16:02, 7 December 2005
\chapter{My First Chapter}
</context>
 
Willi Egger posted the following two examples of a simple line under the chapter title, and a complex graphical element under the chapter title.
 
Here's the simple line:
<texcode>
\setupbackgrounds[header][text][bottomframe=on]
</texcode>
 
Here's the graphical element:
<texcode>
\setupcolors[state=start]
\startuseMPgraphic{HeaderDeco}
numeric w, h, repeats;
path p[];
w := OverlayWidth ; h := OverlayHeight ;
repeats := abs(TextWidth/BodyFontSize);
p[1] := unitsquare xscaled w yscaled h ;
draw p[1] withcolor white;
p[2] := fullcircle scaled BodyFontSize;
p[3] := fullcircle scaled .25BodyFontSize;
draw p[2] shifted (.5BodyFontSize,0);
for i = 1 upto repeats:
if odd i :
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);
else :
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);
fi;
endfor;
\stopuseMPgraphic
 
\setuphead[chapter][command=\Myheader]
\setupheadtext
[chapter=Chapitre]
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]
 
\def\Myheader#1#2{%
\framedtext
[width= \overlaywidth,
height=6\bodyfontsize,
background={foreground,HeaderDeco},
offset=0pt,
strut=no,
frame=off,
align=middle]{%
\headtext{chapter} #1
\blank[small]
#2}}
 
\starttext
\chapter{Here we go!}
\stoptext
</texcode>
 
It looks like:
<context>
\setupcolors[state=start]
\startuseMPgraphic{HeaderDeco}
numeric w, h, repeats;
path p[];
w := OverlayWidth ; h := OverlayHeight ;
repeats := abs(TextWidth/BodyFontSize);
p[1] := unitsquare xscaled w yscaled h ;
draw p[1] withcolor white;
p[2] := fullcircle scaled BodyFontSize;
p[3] := fullcircle scaled .25BodyFontSize;
draw p[2] shifted (.5BodyFontSize,0);
for i = 1 upto repeats:
if odd i :
filldraw p[3] shifted (i*BodyFontSize+.5BodyFontSize,0);
else :
draw p[2] shifted (i*BodyFontSize+.5BodyFontSize,0);
fi;
endfor;
\stopuseMPgraphic
 
\setuphead[chapter][command=\Myheader]
\setupheadtext
[chapter=Chapitre]
\defineoverlay[HeaderDeco][\uniqueMPgraphic{HeaderDeco}]
 
\def\Myheader#1#2{%
\framedtext
[width= \overlaywidth,
height=6\bodyfontsize,
background={foreground,HeaderDeco},
offset=0pt,
strut=no,
frame=off,
align=middle]{%
\headtext{chapter} #1
\blank[small]
#2}}
 
\starttext
\chapter{Here we go!}
\stoptext
</context>
Anonymous user

Navigation menu