1
2
3\startenvironment envexamp
4
5
6
7\usemodule[abr02,mathml]
8
9\setupdocument
10 [color=darkred,
11 columns=2,
12 title=MathML in \ConTeXt]
13
14\startmode[atpragma]
15 \setupbodyfont[lucidanova]
16\stopmode
17
18\startnotmode[atpragma]
19 \setupbodyfont[palatino]
20\stopnotmode
21
22\setupbodyfont
23 [10pt]
24
25\definepapersize
26 [mml]
27 [width=20cm,
28 height=20cm]
29
30\setuppapersize
31 [mml]
32 [mml]
33
34\definecolor[lightgray] [s=.85]
35\definecolor[pagegray] [s=.8]
36\definecolor[mediumgray][s=.5]
37\definecolor[darkgray] [s=.4]
38\definecolor[darkred] [r=.65]
39\definecolor[darkgreen] [g=.65]
40\definecolor[darkblue] [b=.65]
41\definecolor[darkyellow][r=.65,g=.65]
42
43\definepalet
44 [XMLcolorpretty]
45 [ prettyone=darkred,
46 prettytwo=darkgreen,
47 prettythree=darkblue,
48 prettyfour=darkgray]
49
50\definecolor
51 [maincolor]
52 [\documentvariable{color}]
53
54\setuptyping
55 [option=XML]
56
57\setupwhitespace
58 [big]
59
60\setupinteraction
61 [state=start,
62 menu=on,
63 color=maincolor,
64 contrastcolor=maincolor]
65
66\setuplayout
67 [backspace=1cm,
68 topspace=1cm,
69 bottomspace=7.5mm,
70 header=0pt,
71 footer=0pt,
72 bottomdistance=.5cm,
73 bottom=1cm,
74 height=17cm,
75 width=middle]
76
77\defineoverlay [mmlpage] [\uniqueMPgraphic{mmlpage}]
78\defineoverlay [mmltitle] [\uniqueMPgraphic{mmltitle}]
79\defineoverlay [formula] [\uniqueMPgraphic{formula}]
80
81\startuseMPgraphic{mml}
82 z1 = llcorner Page ;
83 z2 = .5[lrcorner Page,urcorner Page] ;
84 z3 = ulcorner Page ;
85 fill
86 Page
87 withcolor \MPcolor{lightgray} ;
88 fill
89 z1 shifted (1cm,0) --
90 z2 shifted (0,-.5cm) --
91 lrcorner Page -- cycle
92 withcolor \MPcolor{pagegray} ;
93 fill
94 z3 shifted (1cm,0) --
95 z2 shifted (0,+.5cm) --
96 urcorner Page -- cycle
97 withcolor \MPcolor{pagegray} ;
98\stopuseMPgraphic
99
100\startuniqueMPgraphic{mmlpage}
101 StartPage ;
102 \includeMPgraphic{mml}
103 fill
104 llcorner Page --
105 .5[lrcorner Page,urcorner Page] --
106 ulcorner Page -- cycle
107 withcolor \MPcolor{pagegray} ;
108 Page := Page enlarged -.5cm ;
109 StopPage ;
110\stopuniqueMPgraphic
111
112\startuniqueMPgraphic{mmltitle}
113 StartPage ;
114 \includeMPgraphic{mml}
115 fill z1z2z3cycle withcolor \MPcolor{maincolor} ;
116 picture p ;
117 p := textext("\documentvariable{title}") ;
118 p := p xsized (.75length(z2z1)) ;
119 p := p rotatedaround(center p, angle z2) ;
120 p := p shifted center p shifted .5[z1,z2] ;
121 p := p shifted ((unitvector(.5[z1,z2]) rotated 90)1cm) ;
122 draw p withcolor \MPcolor{lightgray} ;
123 Page := Page enlarged -.5cm ;
124 StopPage ;
125\stopuniqueMPgraphic
126
127\startuniqueMPgraphic{formula}
128 draw
129 OverlayBox
130 withpen pensquare scaled 2mm
131 withcolor \MPcolor{lightgray} ;
132 fill
133 OverlayBox
134 withcolor \MPcolor{mediumgray} ;
135\stopuniqueMPgraphic
136
137\setupbottom
138 [style=bold,
139 color=darkgray]
140
141\setuplist
142 [section]
143 [alternative=a,
144 interaction=all,
145 pagenumber=no,
146 width=0pt,
147 style=\bfb,
148 color=darkgray,
149 contrastcolor=darkgray,
150 before={\blank[2*big]},
151 after={\blank\startcolumns[n=5]\placelist[subsection]\stopcolumns}]
152
153\setuplist
154 [subsection]
155 [alternative=f,
156 interaction=all]
157
158\setuphead
159 [section]
160 [page=yes,
161 style=\bfd,
162 color=darkgray,
163 number=no,
164 after={\blank[2*big]\startcolumns[n=5]\placelist[subsection]\stopcolumns\page}]
165
166\setuphead
167 [subsection]
168 [after=,
169 placehead=empty]
170
171\setuphead
172 [subject]
173 [style=\bfb,
174 color=darkgray,
175 after={\blank[2*big]}]
176
177\setupinteractionmenu
178 [bottom]
179 [state=start,
180 frame=off,
181 left=\hskip3cm,
182 middle=\quad]
183
184\startinteractionmenu[bottom]
185 \startbut [content] content \stopbut
186 \startbut [colofon] colofon \stopbut
187 \startbut [index] index \stopbut
188 \startbut [PreviousJump] go back \stopbut
189 \startbut [previouspage] \bfa \stopbut
190 \startbut [nextpage] \bfa \stopbut
191 \hfill
192 \starttxt
193 \color[darkgray]{\markcontent{\getmarking[section]: }\getmarking[subsection]\removemarkedcontent}
194 \stoptxt
195\stopinteractionmenu
196
197\starttexdefinition unexpanded ShowFormula #1#2#3
198 \showXMLformula{\rawstructurelistuservariable{filename}.xml}
199\stoptexdefinition
200
201\starttexdefinition unexpanded showXMLformula #1
202 \framed [
203 strut=no,
204 background=formula,
205 foregroundcolor=white,
206 frame=off,align=normal,
207 width=\hsize
208 ] {
209 \vbox {
210 \processXMLfile{#1}\endgraf
211 }
212 }
213\stoptexdefinition
214
215\starttexdefinition unexpanded showXMLsample #1
216 \page
217 \bgroup
218 \startbaselinecorrection
219 \showXMLformula{#1.xml}
220 \stopbaselinecorrection
221 \startsubsection[reference=#1,title=#1,marking=#1][filename=#1]
222 \switchtobodyfont
223 [8pt]
224 \startcolumns[balance=no,n=\documentvariable{columns}]
225 \typefile{#1.xml}
226 \stopcolumns
227 \vfill
228 \page
229 \stopsubsection
230 \egroup
231\stoptexdefinition
232
233\startsetups[document:start]
234
235 \setupbackgrounds
236 [page]
237 [background=mmltitle]
238
239 \startstandardmakeup
240 \setupalign[left]
241 \bgroup
242 \darkgray \bfd \setupinterlinespace
243 Examples \vfill
244 Hans Hagen\par
245 PRAGMA ADE\par
246 \vskip\dp\strutbox
247 \vskip1cm
248 \egroup
249 \vskip\dp\strutbox
250 \vskip1pt
251 \stopstandardmakeup
252
253 \setupbackgrounds
254 [page]
255 [background=mmlpage]
256
257 \startsubject[reference=content,title={Content}]
258 \placelist[section]
259 \stopsubject
260
261 \startsubject[reference=colofon,titlr={Colofon}]
262 \getbuffer[colofon]
263 \stopsubject
264
265\stopsetups
266
267\startsetups[document:stop]
268
269 \page
270
271 \pagereference[index]
272
273 \setuplist
274 [section]
275 [alternative=a,
276 before={\testpage[5]},
277 after={\blank[medium]\placelist[subsection]}]
278
279 \setuplist
280 [subsection]
281 [alternative=vertical,
282 before=\startbaselinecorrection,
283 after=\stopbaselinecorrection\blank,
284 color=,
285 contrastcolor=,
286 command=\ShowFormula,
287 interaction=all]
288
289 \placelist[section][criterium=text]
290
291\stopsetups
292
293\stopenvironment
294 |