fix getsup (HH)
[luatex.git] / manual / luatex-style.tex
blob20e19510a8db80b70e9363e246a55ac16633cf5a
1 \startenvironment luatex-style
3 % todo: use \useMPlibrary[lua]
5 \usemodule[abr-02]
7 \setuplayout
8 [height=middle,
9 width=middle,
10 backspace=2cm,
11 topspace=10mm,
12 bottomspace=10mm,
13 header=10mm,
14 footer=10mm,
15 footerdistance=10mm,
16 headerdistance=10mm]
18 \setuppagenumbering
19 [alternative=doublesided]
21 \setuptolerance
22 [stretch,tolerant]
24 \setuptype
25 [lines=hyphenated]
27 \setuptyping
28 [lines=hyphenated]
30 \setupitemize
31 [each]
32 [packed]
34 \setupwhitespace
35 [medium]
37 \startluacode
38 local skipped = table.tohash { 'id', 'subtype', 'next', 'prev' }
40 function document.functions.showfields(s)
41 local t = string.split(s,',')
42 local f = node.fields(t[1],t[2])
43 if f then
44 local d = false
45 for i=1,#f do
46 local fi = f[i]
47 if skipped[fi] then
48 -- okay
49 elseif d then
50 context(', {\tttf %s}', fi)
51 else
52 context('{\tttf %s}', fi)
53 d = true
54 end
55 end
56 end
57 end
59 function document.functions.showid(s)
60 local t = string.split(s,',')
61 context('{tttf %s}',node.id(t[1]))
62 if t[2] then
63 context(', {tttf %s}',node.subtype(t[2]))
64 end
65 end
67 function document.functions.showsubtypes(s)
68 local s = node.subtypes(s)
69 local d = false
70 for k, v in table.sortedhash(s) do
71 if d then
72 context(', %s = {\\tttf %s}',k,v)
73 else
74 context('%s = {\\tttf %s}',k,v)
75 d = true
76 end
77 end
78 end
79 \stopluacode
81 \unexpanded\def\showfields #1{\ctxlua{document.functions.showfields("#1")}}
82 \unexpanded\def\showid #1{\ctxlua{document.functions.showid("#1")}}
83 \unexpanded\def\showsubtypes#1{\ctxlua{document.functions.showsubtypes("#1")}}
85 \definecolor[blue] [b=.5]
86 \definecolor[red] [r=.5]
87 \definecolor[green] [g=.5]
88 \definecolor[maincolor] [b=.5]
89 \definecolor[keptcolor] [b=.5]
90 \definecolor[othercolor][r=.5,g=.5]
92 \setupbodyfont[modern] % we need this in examples so we predefine
94 % \doifmodeelse {atpragma} {
96 % % \setupbodyfont
97 % % [lucidaot,10pt]
99 % \setupbodyfont
100 % [dejavu,10pt]
102 % \setuphead [chapter] [style=\bfd]
103 % \setuphead [section] [style=\bfb]
104 % \setuphead [subsection] [style=\bfa]
105 % \setuphead [subsubsection][style=\bf]
107 % } {
109 % \definetypeface[mainfacenormal] [ss][sans] [iwona] [default]
110 % \definetypeface[mainfacenormal] [rm][serif][palatino] [default]
111 % \definetypeface[mainfacenormal] [tt][mono] [modern] [default][rscale=1.1]
112 % \definetypeface[mainfacenormal] [mm][math] [iwona] [default]
114 % \definetypeface[mainfacemedium] [ss][sans] [iwona-medium][default]
115 % \definetypeface[mainfacemedium] [rm][serif][palatino] [default]
116 % \definetypeface[mainfacemedium] [tt][mono] [modern] [default][rscale=1.1]
117 % \definetypeface[mainfacemedium] [mm][math] [iwona-medium][default]
119 % \setupbodyfont
120 % [mainfacenormal,10pt]
122 % \setuphead [chapter] [style=\mainfacemedium\bfd]
123 % \setuphead [section] [style=\mainfacemedium\bfb]
124 % \setuphead [subsection] [style=\mainfacemedium\bfa]
125 % \setuphead [subsubsection][style=\mainfacemedium\bf]
129 \writestatus{luatex manual}{we assume that dejavu math is available}
131 \setupbodyfont % assumes dejavu-math
132 [dejavu,10pt]
134 \setuphead [chapter] [align={flushleft,broad},style=\bfd]
135 \setuphead [section] [align={flushleft,broad},style=\bfb]
136 \setuphead [subsection] [align={flushleft,broad},style=\bfa]
137 \setuphead [subsubsection][align={flushleft,broad},style=\bf]
139 \setuphead [chapter] [color=maincolor]
140 \setuphead [section] [color=maincolor]
141 \setuphead [subsection] [color=maincolor]
142 \setuphead [subsubsection][color=maincolor]
144 \definehead
145 [remark]
146 [subsubsubject]
148 \setupheadertexts
151 \definemixedcolumns
152 [twocolumns]
153 [n=2,
154 balance=yes,
155 before=\blank,
156 after=\blank]
158 \definemixedcolumns
159 [threecolumns]
160 [twocolumns]
161 [n=3]
163 \definemixedcolumns
164 [fourcolumns]
165 [threecolumns]
166 [n=4]
168 % if we do this we also need to do it in table cells
170 % \setuptyping
171 % [color=maincolor]
173 % \setuptype
174 % [color=maincolor]
176 \definetyping
177 [functioncall]
179 \startMPdefinitions
181 color luaplanetcolor ; luaplanetcolor := \MPcolor{maincolor} ;
182 color luaholecolor ; luaholecolor := white ;
183 numeric luaextraangle ; luaextraangle := 0 ;
184 numeric luaorbitfactor ; luaorbitfactor := .25 ;
186 vardef lualogo = image (
188 % Graphic design by A. Nakonechnyj. Copyright (c) 1998, All rights reserved.
190 save d, r, p ; numeric d, r, p ;
192 d := sqrt(2)/4 ; r := 1/4 ; p := r/8 ;
194 fill fullcircle scaled 1
195 withcolor luaplanetcolor ;
196 draw fullcircle rotated 40.5 scaled (1+r)
197 dashed evenly scaled p
198 withpen pencircle scaled (p/2)
199 withcolor (luaorbitfactor * luaholecolor) ;
200 fill fullcircle scaled r shifted (d+1/8,d+1/8)
201 rotated - luaextraangle
202 withcolor luaplanetcolor ;
203 fill fullcircle scaled r shifted (d-1/8,d-1/8)
204 withcolor luaholecolor ;
205 luaorbitfactor := .25 ;
206 ) enddef ;
208 \stopMPdefinitions
210 \startuseMPgraphic{luapage}
211 StartPage ;
213 fill Page withcolor \MPcolor{othercolor} ;
215 luaorbitfactor := 1 ;
216 picture p ; p := lualogo xsized (3PaperWidth/5) ;
217 draw p shifted center Page shifted (0,-.5ypart center ulcorner p) ;
219 StopPage ;
220 \stopuseMPgraphic
222 % \starttexdefinition luaextraangle
223 % % we can also just access the last page and so in mp directly
224 % \ctxlua {
225 % context(\lastpage == 0 and 0 or \realfolio*360/\lastpage)
227 % \stoptexdefinition
229 \startuseMPgraphic{luanumber}
230 % luaextraangle := \luaextraangle;
231 luaextraangle := if (LastPageNumber == 0) : 0 else : (RealPageNumber / LastPageNumber) * 360 fi;
232 luaorbitfactor := 0.25 ;
233 picture p ; p := lualogo ;
234 setbounds p to boundingbox fullcircle ;
235 draw p ysized 1cm ;
236 \stopuseMPgraphic
238 \definelayer
239 [page]
240 [width=\paperwidth,
241 height=\paperheight]
243 \setupbackgrounds
244 [leftpage]
245 [background=page]
247 \setupbackgrounds
248 [rightpage]
249 [background=page]
251 \startsetups pagenumber:right
252 \setlayerframed
253 [page]
254 [preset=rightbottom,offset=1cm]
255 [frame=off,height=1cm,offset=overlay]
256 {\useMPgraphic{luanumber}}
257 \setlayerframed
258 [page]
259 [preset=rightbottom,offset=1cm,x=1.5cm]
260 [frame=off,height=1cm,width=1cm,offset=overlay]
261 {\pagenumber}
262 \setlayerframed
263 [page]
264 [preset=rightbottom,offset=1cm,x=2.5cm]
265 [frame=off,height=1cm,offset=overlay]
266 {\getmarking[chapter]}
267 \stopsetups
269 \startsetups pagenumber:left
270 \setlayerframed
271 [page]
272 [preset=leftbottom,offset=1cm,x=2.5cm]
273 [frame=off,height=1cm,offset=overlay]
274 {\getmarking[chapter]}
275 \setlayerframed
276 [page]
277 [preset=leftbottom,offset=1cm,x=1.5cm]
278 [frame=off,height=1cm,width=1cm,offset=overlay]
279 {\pagenumber}
280 \setlayerframed
281 [page]
282 [preset=leftbottom,offset=1cm]
283 [frame=off,height=1cm,offset=overlay]
284 {\useMPgraphic{luanumber}}
285 \stopsetups
287 \unexpanded\def\nonterminal#1>{\mathematics{\langle\hbox{\rm #1}\rangle}}
289 % taco's brainwave -) .. todo: create a typing variant so that we can avoid the !crlf
291 \newcatcodetable\syntaxcodetable
293 \unexpanded\def\makesyntaxcodetable
294 {\begingroup
295 \catcode`\<=13 \catcode`\|=12
296 \catcode`\!= 0 \catcode`\\=12
297 \savecatcodetable\syntaxcodetable
298 \endgroup}
300 \makesyntaxcodetable
302 \unexpanded\def\startsyntax {\begingroup\catcodetable\syntaxcodetable \dostartsyntax}
303 \unexpanded\def\syntax {\begingroup\catcodetable\syntaxcodetable \dosyntax}
304 \let\stopsyntax \relax
306 \unexpanded\def\syntaxenvbody#1%
307 {\par
309 \startnarrower
310 \maincolor #1
311 \stopnarrower
312 \par}
314 \unexpanded\def\syntaxbody#1%
315 {\begingroup
316 \maincolor \tt #1%
317 \endgroup}
319 \bgroup \catcodetable\syntaxcodetable
321 !gdef!dostartsyntax#1\stopsyntax{!let<!nonterminal!syntaxenvbody{#1}!endgroup}
322 !gdef!dosyntax #1{!let<!nonterminal!syntaxbody{#1}!endgroup}
324 !egroup
326 \definetyping
327 [texsyntax]
328 [color=maincolor]
330 % end of wave
332 \setupinteraction
333 [state=start,
334 focus=standard,
335 style=,
336 color=,
337 contrastcolor=]
339 \placebookmarks
340 [chapter,section,subsection]
342 \setuplist
343 [chapter,section,subsection,subsubsection]
344 [interaction=all,
345 width=3em]
347 \setuplist
348 [chapter]
349 [style=bold,
350 color=keptcolor]
352 \setuplist
353 [subsection,subsubsection]
354 [margin=3em,
355 width=5em]
357 % Hans doesn't like the bookmarks opening by default so we comment this:
359 % \setupinteractionscreen
360 % [option=bookmark]
362 \stopenvironment