MetaFun - Pragma ADE
MetaFun - Pragma ADE MetaFun - Pragma ADE
162 offset=\bodyfontsize, before={\blank[big,medium]}, after={\blank[big]}, width=\textwidth] There is one drawback: when your left and right margin have different dimensions, the text will be scaled differently on odd and even pages. Normally this is no problem for a draft. As an alternative you can use the \setuptexts command and wrap the graphic in a box with the right dimensions, using code like: \startuniqueMPgraphic{copyright} picture p ; p := btex COPYRIGHT etex rotated 90 ; setbounds p to boundingbox p enlarged 1pt ; draw p withcolor .8white ; xyscale_currentpicture(\the\leftmarginwidth,\the\textheight) ; \stopuniqueMPgraphic \setuptexttexts [margin] [] [\uniqueMPgraphic{copyright}] The graphic goes into the outer margin. The second argument can be used to put something in the inner margin. 6.3 Multiple overlays You can stack overlays. Consider the next case, where we assume that you have enabled interaction support using \setupinteraction[state=start]: \setupbackgrounds [page] [background={color,nextpage}, backgroundcolor=darkyellow] Here, the page gets a colored background and a hyperlink to the next page, previously defined by: \defineoverlay[nextpage][\overlaybutton{nextpage}] An \overlaybutton is just a button, with all attributes (color, frame, etc) set to nothing, having the dimensions of the overlay. The argument is one of the permitted destinations, like nextpage, firstpage, SearchDocument and alike. For efficiency reasons, the background areas (like [text][text]) are calculated only when their definition has changed. When a background changes per page, we have to recalculate it on each page. In the next example, the macro \overlaybutton generates a different button on each page. But, since we don't explicitly set the background at each page, there is no way the background drawing mechanism can know that this button has changed. Therefore, we must force recalculation with: \setupbackgrounds[state=repeat] Page backgrounds Multiple overlays
You can test this concept yourself with the following code. Here we assume that you have a file called tufte.tex on your system, which is the case if you have CONTEXT installed. However, you can just as easily use any file having a paragraph of two of text. \starttext \setupinteraction[state=start] \setupbackgrounds[state=repeat] \defineoverlay[nextpage][\overlaybutton{nextpage}] \setupbackgrounds[text][text][background=nextpage] \dorecurse{20}{\input tufte \par} \stoptext Note that you can move forward from page to page in the resulting PDF file by clicking on each page with the mouse. Now compile this file without setting the background state to repeat and note the difference as you click pages with the mouse. Setting the state was not needed when we used the page background: \setupbackgrounds[page][background=nextpage] The \dorecurse macro is handy for testing since it saves us typing. One can nest this macro as in: \dorecurse{20}{\dorecurse{10}{Hello World! }\par} The current step is available in \recurselevel and the depth (nesting level) in \recursedepth. 6.4 Crossing borders In many cases, the previously mentioned background areas will suffice, but in the case of more complicated backgrounds, you may wish to use METAPOST to draw graphics that combine or span these areas. At runtime CONTEXT saves information on the layout that can be picked up by METAPOST. The framework for a page graphic is: StartPage; % all kind of commands StopPage ; Between the StartPage and StopPage command you have access to a wide range of variables: page PaperHeight PaperWidth PrintPaperHeight PrintPaperWidth PageOffset PageDepth margins TopSpace BackSpace text MakeupHeight MakeupWidth vertical TopHeight TopDistance HeaderHeight HeaderDistance TextHeight FooterDistance FooterHeight Crossing borders Page backgrounds 163
- Page 115 and 116: 3 Embedded graphics In addition to
- Page 117 and 118: \startMPcode fill fullcircle scaled
- Page 119 and 120: \startuniqueMPgraphic{right or wron
- Page 121 and 122: {\externalfigure[mprun:extrafun::my
- Page 123 and 124: \startlinecorrection[blank] \proces
- Page 125 and 126: In order to prevent problems, we ad
- Page 127 and 128: There are a few more low level swit
- Page 129 and 130: When we convert color to gray, we u
- Page 131 and 132: 4 Enhancing the layout One of the m
- Page 133 and 134: 4.2 Overlay variables [offset=3pt,f
- Page 135 and 136: This background demonstrates that a
- Page 137 and 138: As you may know, TEX's ambassador i
- Page 139 and 140: This works as expected: \RotatedTex
- Page 141 and 142: We will now apply this knowledge of
- Page 143 and 144: p := p shifted (2o,OverlayHeight-yp
- Page 145 and 146: We demonstrated that when defining
- Page 147 and 148: 5 Positional graphics In this chapt
- Page 149 and 150: 5.2 Anchors and layers In a previou
- Page 151 and 152: pab := pab cutafter (pab intersecti
- Page 153 and 154: fill p withcolor \MPcolor{lightgray
- Page 155 and 156: The previous example also demonstra
- Page 157 and 158: \setMPlayer [test] [somepos-1] [loc
- Page 159 and 160: 6 Page backgrounds Especially in in
- Page 161 and 162: As soon as you want to make an elec
- Page 163 and 164: do_it (1,4,false) ; do_it (5,4,fals
- Page 165: gigigi Watch how the bounding boxes
- Page 169 and 170: StartPage ; fill Area[Text][Text] s
- Page 171 and 172: fi ; Main := Main enlarged 6pt ; pi
- Page 173 and 174: ulcorner Field[Text] [Text] -urcorn
- Page 175 and 176: The left picture demonstrates what
- Page 177 and 178: There are two more operators: inner
- Page 179 and 180: 7 Shapes, symbols and buttons One c
- Page 181 and 182: Table 7.1 demonstrates how scratch
- Page 183 and 184: for i := 1 upto \MPvar{n} : xpos :=
- Page 185 and 186: This table is defined as: \bTABLE[f
- Page 187 and 188: Since we have collected some nice b
- Page 189 and 190: 8 Special effects Sometimes we want
- Page 191 and 192: Because of this implementation, sha
- Page 193 and 194: test_shade(origin shifted (.25cm,0)
- Page 195 and 196: fill p shifted (3cm,0) withcolor .5
- Page 197 and 198: \definecolor [tred] [r=1,t=.5,a=exc
- Page 199 and 200: Figure 8.4 Another clipped cow. \pl
- Page 201 and 202: withpen pencircle scaled 4mm withco
- Page 203 and 204: Because this graphic is the result
- Page 205 and 206: The resulting PDF file can be inclu
- Page 207 and 208: Including another METAPOST graphic,
- Page 209 and 210: After these examples your are proba
- Page 211 and 212: In this graphic, we have two text f
- Page 213 and 214: } {}} Here we feed some MATHML int
- Page 215 and 216: 9 Functions METAPOST provides a wid
You can test this concept yourself with the following code. Here we assume that you have a file<br />
called tufte.tex on your system, which is the case if you have CONTEXT installed. However, you<br />
can just as easily use any file having a paragraph of two of text.<br />
\starttext<br />
\setupinteraction[state=start]<br />
\setupbackgrounds[state=repeat]<br />
\defineoverlay[nextpage][\overlaybutton{nextpage}]<br />
\setupbackgrounds[text][text][background=nextpage]<br />
\dorecurse{20}{\input tufte \par}<br />
\stoptext<br />
Note that you can move forward from page to page in the resulting PDF file by clicking on each<br />
page with the mouse. Now compile this file without setting the background state to repeat and<br />
note the difference as you click pages with the mouse.<br />
Setting the state was not needed when we used the page background:<br />
\setupbackgrounds[page][background=nextpage]<br />
The \dorecurse macro is handy for testing since it saves us typing. One can nest this macro as in:<br />
\dorecurse{20}{\dorecurse{10}{Hello World! }\par}<br />
The current step is available in \recurselevel and the depth (nesting level) in \recursedepth.<br />
6.4 Crossing borders<br />
In many cases, the previously mentioned background areas will suffice, but in the case of more<br />
complicated backgrounds, you may wish to use METAPOST to draw graphics that combine or span<br />
these areas.<br />
At runtime CONTEXT saves information on the layout that can be picked up by METAPOST. The framework<br />
for a page graphic is:<br />
StartPage;<br />
% all kind of commands<br />
StopPage ;<br />
Between the StartPage and StopPage command you have access to a wide range of variables:<br />
page PaperHeight PaperWidth<br />
PrintPaperHeight PrintPaperWidth<br />
PageOffset PageDepth<br />
margins TopSpace BackSpace<br />
text MakeupHeight MakeupWidth<br />
vertical TopHeight TopDistance<br />
HeaderHeight HeaderDistance<br />
TextHeight<br />
FooterDistance FooterHeight<br />
Crossing borders Page backgrounds<br />
163