Changes

Jump to navigation Jump to search
m
}}
== [[Help:Reference|Syntax]] (autogenerated) ==
<syntax>setupbackgrounds</syntax>
== [[Help:Reference|Syntax]] ==
<table cellspacing="4" cellpadding="2" class="cmd">
</table>
== Description == <code>\{{cmd|setupbackgrounds</code> }} is used to draw frames or backgrounds that cover specific areas of the page, under the text layer. It is especially used in combination with the
* The first parameter sets the main layout area; * the optional second one specifies the linked subarea(s) of the prior. Not all main areas have such subareas.* about the third parameter** the key <code>state</code> determines when the page background is recalculated.***<code>state=repeat</code> ensures that the page background is always recalculated (useful if you want to use a variable that depends on the current page, such as its number with {{cmd|realpageno}}).*** <code>state=start</code> recalculates the page background, and stops its automatic recalculation,*** <code>state=stop</code> doesn't recalculate the page background, and stops its automatic recalculation.
Because {{cmd|showframe}} and <code>\{{cmd|setupbackgrounds</code> }} both draw frameboxes over parts of the page, the order in which they are invoked matters. In most cases, {{cmd|setupbackgrounds}} should come last. Backgrounds are essential for working with [[Layers]]. You enable your defined layers like <code>\setupbackgrounds[page][background=mylayer]</code>. The <code>background</code> key also takes a list, and if you include "foreground", you can also set something on top of your general content, e.g. <code>\setupbackgrounds[page][background={mybacklayer,foreground,mytoplayer}]</code> should come last.
== Example ==
<context source=yes>
\setuppapersize[A10A7]
\showframe
% \setupbackgrounds should be placed *after* \showframe,
\setupbackgrounds[footer] [background=color, backgroundcolor=blue]\setupbackgrounds[footer] [leftmargin] [background=color, backgroundcolor=red]\setupbackgrounds [text] [background=color, backgroundcolor=lightgray]\setupbackgrounds [text] [rightmargin] [background=color, backgroundcolor=yellow] \starttextI paint modern\stoptext</context> === Example of dynamic positioning of page numbering ===
<context source=yes>\setupbackgroundssetuppapersize[textA6] [background=color, backgroundcolor=lightgrayA6]\setupbackgrounds[textstate=repeat] [rightmargin] [background%\showframe\startuseMPgraphic{MonGraphismeV_MP} numeric h ; h := \overlayheight ; numeric w ; w := \overlaywidth ; numeric n ; n := \number\realpageno ; numeric m ; m := \number\lastpageno ; numeric ratio ; ratio :=color, backgroundcolor(1-n/(m+1)); numeric e ; e :=yellow]0.3mm;
I paint modern picture pa ; pa := textext.raw(btex {\strut\the\realpageno} etex) ; numeric wpa ; wpa := xpart (urcorner pa - ulcorner pa); numeric hpa ; hpa := ypart (ulcorner pa - llcorner pa);  pa := pa shifted (-wpa/2 + w/2, ratio * (h-hpa)); pair paA ; paA:= ((ulcorner pa) + (urcorner pa)) / 2 ; pair paB ; paB:= ((llcorner pa) + (lrcorner pa)) / 2 ;  draw ((w/2,0)--paB) dashed withdots withpen pencircle scaled e withcolor darkred; draw ((w/2,h)--paA) dashed withdots withpen pencircle scaled e withcolor darkred; draw pa withcolor darkred;\stopuseMPgraphic \startuseMPgraphic{MonGraphismeH_MP} numeric h ; h := \overlayheight ; numeric w ; w := \overlaywidth ; numeric n ; n := \number\realpageno ; numeric m ; m := \number\lastpageno ; numeric ratio ; ratio := (n/(m+1)); numeric e ; e := 0.3mm;  picture pa ; pa := textext.raw(btex {\strut\the\realpageno} etex) ; numeric wpa ; wpa := xpart (urcorner pa - ulcorner pa); numeric hpa ; hpa := ypart (ulcorner pa - llcorner pa);  pa := pa shifted (ratio * (w-wpa),-hpa/2 + h/2); pair paA ; paA:= ((ulcorner pa) + (llcorner pa)) / 2 ; pair paB ; paB:= ((urcorner pa) + (lrcorner pa)) / 2 ;  draw ((0,h/2)--paA) dashed withdots withpen pencircle scaled e withcolor darkred; draw ((w,h/2)--paB) dashed withdots withpen pencircle scaled e withcolor darkred; draw pa withcolor darkred;\stopuseMPgraphic \defineoverlay [MonGraphismeV_OL] [\useMPgraphic{MonGraphismeV_MP}]\defineoverlay [MonGraphismeH_OL] [\useMPgraphic{MonGraphismeH_MP}] \setupbackgrounds [text] [rightmargin] [background={MonGraphismeV_OL}]\setupbackgrounds [footer] [text] [background={MonGraphismeH_OL}] \starttext \dorecurse{4}{\input tufte\page} \stoptext
</context>
== See also ==
* [[Layers]]
* {{cmd|setupframed}}, which is the mechanism used by \setupbackgrounds.
1,031

edits

Navigation menu