Changes

Jump to navigation Jump to search
m
<!-- please remove this and the following line if you have checked this page -->
{{Reference_Cleanup}}
{{Reference
|name=setupbackgrounds
}}
== [[Help:Reference|Syntax]] (autogenerated) ==
<syntax>setupbackgrounds</syntax>
== [[Help:Reference|Syntax]] ==
<table cellspacing="4" cellpadding="2" class="cmd">
</tr>
<tr valign="top" class="third">
<td class="cmd">[[Reference/enCommand/keyword:state|state]]</td> <td>[[Reference/enCommand/value:start|start]] [[Reference/enCommand/value:stop|stop]] [[Reference/enCommand/value:repeat|repeat]] </td>
</tr>
<tr valign="top" class="third">
<td class="cmd">[...,...=...,...]</td>
<td>see [[Reference/enCommand/setupframed|\setupframed]] </td>
</tr>
</table>
== Description ==
{{cmd|setupbackgrounds}} is used to draw frames or backgrounds that cover specific areas of the page, under the text layer.
* 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= Description == start</code> recalculates the page background, and stops its automatic recalculation,*** <code>state== comment ==stop</code> doesn't recalculate the page background, and stops its automatic recalculation.
The first parameter sets Because {{cmd|showframe}} and {{cmd|setupbackgrounds}} both draw frameboxes over parts of the main layout areapage, the second one specifies the linked subarea(s) of the priororder in which they are invoked matters. Not all main areas have such subareasIn 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>.
== Example ==
<context source=yes>\setuppapersize[A7]\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>\setuppapersize[A6][A6]\setupbackgrounds[state=repeat]%\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 := (1-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 (-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}]
'''[text]''' has several linked subareas.<pre class="example">\setupbackgrounds[text] [background=color,backgroundcolor=lightgray]\setupbackgrounds[text] [leftmargin] [background=color,backgroundcolor=red]</pre>starttext
sets a light gray background for the text area and a red background for the left margin area.\dorecurse{4}{\input tufte\page}
\stoptext
</context>
== See also ==
<!-- something like * [[Layers]]* {{cmd:goto|setupframed}}, which is the mechanism used by \goto]] setupbackgrounds. == Help from ConTeXt-->Mailinglist/Forum ==All issues with:{{Forum|{{SUBPAGENAME}}}}
[[Category:ReferenceCommand/enBackgrounds|setupbackgrounds]]
1,031

edits

Navigation menu