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