Debian Codegraph @

texmf-dist/doc/luatex/base/luatex-style.tex

raw
1 \startenvironment luatex-style
2
3 % todo: use \useMPlibrary[lua]
4
5 \enabletrackers[fonts.usage]
6
7 \usemodule[fonts-statistics]
8
9 \setuplayout
10 [height=middle,
11 width=middle,
12 backspace=2cm,
13 topspace=10mm,
14 bottomspace=10mm,
15 header=10mm,
16 footer=10mm,
17 footerdistance=10mm,
18 headerdistance=10mm]
19
20 \setuppagenumbering
21 [alternative=doublesided]
22
23 \setuptolerance
24 [stretch,tolerant]
25
26 \setuptype
27 [lines=hyphenated]
28
29 \setuptyping
30 [lines=hyphenated]
31
32 \setupitemize
33 [each]
34 [packed]
35
36 \definesymbol[1][\Uchar"2023]
37 \definesymbol[2][\endash]
38 \definesymbol[3][\wait] % we want to catch it
39
40 \setupitemize
41 [each]
42 [headcolor=maincolor,
43 symbolcolor=maincolor,
44 color=maincolor]
45
46 \setupwhitespace
47 [medium]
48
49 \setuptabulate
50 [blank={small,samepage},
51 headstyle=bold,
52 rulecolor=maincolor,
53 rulethickness=1pt,
54 foregroundcolor=white,
55 foregroundstyle=\ss\bfx\WORD,
56 backgroundcolor=maincolor]
57
58 \setupcaptions
59 [headcolor=darkblue]
60
61 \startluacode
62 local skipped = table.tohash { 'id', 'subtype', 'next', 'prev' }
63
64 function document.functions.showfields(s)
65 local t = string.split(s,',')
66 local f = node.fields(t[1],t[2])
67 if f then
68 local d = false
69 for i=1,#f do
70 local fi = f[i]
71 if skipped[fi] then
72 -- okay
73 elseif d then
74 context(', {\tttf %s}', fi)
75 else
76 context('{\tttf %s}', fi)
77 d = true
78 end
79 end
80 end
81 end
82
83 function document.functions.showid(s)
84 local t = string.split(s,',')
85 context('{tttf %s}',node.id(t[1]))
86 if t[2] then
87 context(', {tttf %s}',node.subtype(t[2]))
88 end
89 end
90
91 function document.functions.showsubtypes(s)
92 local s = node.subtypes(s)
93 local d = false
94 for k, v in table.sortedhash(s) do
95 if d then
96 context(', %s = {\\tttf %s}',k,v)
97 else
98 context('%s = {\\tttf %s}',k,v)
99 d = true
100 end
101 end
102 end
103 \stopluacode
104
105 \unexpanded\def\showfields #1{\ctxlua{document.functions.showfields("#1")}}
106 \unexpanded\def\showid #1{\ctxlua{document.functions.showid("#1")}}
107 \unexpanded\def\showsubtypes#1{\ctxlua{document.functions.showsubtypes("#1")}}
108
109 \definecolor[blue] [b=.5]
110 \definecolor[red] [r=.5]
111 \definecolor[green] [g=.5]
112 \definecolor[maincolor] [b=.5]
113 \definecolor[keptcolor] [b=.5]
114 \definecolor[othercolor][r=.5,g=.5]
115
116 \writestatus{luatex manual}{}
117 \writestatus{luatex manual}{defining lucodaot} \usebodyfont [lucidaot]
118 \writestatus{luatex manual}{defining pagella} \usebodyfont [pagella]
119 \writestatus{luatex manual}{defining cambria} \usebodyfont [cambria]
120 \writestatus{luatex manual}{defining modern} \usebodyfont [modern]
121 \writestatus{luatex manual}{defining dejavu} \setupbodyfont[dejavu,10pt]
122 \writestatus{luatex manual}{}
123
124 \setuphead [chapter] [align={flushleft,broad},style=\bfd]
125 \setuphead [section] [align={flushleft,broad},style=\bfb]
126 \setuphead [subsection] [align={flushleft,broad},style=\bfa]
127 \setuphead [subsubsection][align={flushleft,broad},style=\bf]
128
129 \setuphead [chapter] [color=maincolor]
130 \setuphead [section] [color=maincolor]
131 \setuphead [subsection] [color=maincolor]
132 \setuphead [subsubsection][color=maincolor]
133
134 \setupfloats
135 [ntop=4]
136
137 \definehead
138 [remark]
139 [subsubsubject]
140
141 \setupheadertexts
142 []
143
144 % \setuplayout
145 % [style=bold,
146 % color=maincolor]
147
148 \definemixedcolumns
149 [twocolumns]
150 [n=2,
151 balance=yes,
152 before=\blank,
153 after=\blank]
154
155 \definemixedcolumns
156 [threecolumns]
157 [twocolumns]
158 [n=3]
159
160 \definemixedcolumns
161 [fourcolumns]
162 [threecolumns]
163 [n=4]
164
165 % if we do this we also need to do it in table cells
166 %
167 % \setuptyping
168 % [color=maincolor]
169 %
170 % \setuptype
171 % [color=maincolor]
172
173 \definetyping
174 [functioncall]
175
176 \startMPdefinitions
177
178 color luaplanetcolor ; luaplanetcolor := \MPcolor{maincolor} ;
179 color luaholecolor ; luaholecolor := white ;
180 numeric luaextraangle ; luaextraangle := 0 ;
181 numeric luaorbitfactor ; luaorbitfactor := .25 ;
182
183 vardef lualogo = image (
184
185 % Graphic design by A. Nakonechnyj. Copyright (c) 1998, All rights reserved.
186
187 save d, r, p ; numeric d, r, p ;
188
189 d := sqrt(2)/4 ; r := 1/4 ; p := r/8 ;
190
191 fill fullcircle scaled 1
192 withcolor luaplanetcolor ;
193 draw fullcircle rotated 40.5 scaled (1+r)
194 dashed evenly scaled p
195 withpen pencircle scaled (p/2)
196 withcolor (luaorbitfactor * luaholecolor) ;
197 fill fullcircle scaled r shifted (d+1/8,d+1/8)
198 rotated - luaextraangle
199 withcolor luaplanetcolor ;
200 fill fullcircle scaled r shifted (d-1/8,d-1/8)
201 withcolor luaholecolor ;
202 luaorbitfactor := .25 ;
203 ) enddef ;
204
205 \stopMPdefinitions
206
207 \startuseMPgraphic{luapage}
208 StartPage ;
209
210 fill Page withcolor \MPcolor{othercolor} ;
211
212 luaorbitfactor := 1 ;
213
214 picture p ; p := lualogo ysized (5*\measure{paperheight}/10) ;
215 draw p
216 shifted - center p
217 shifted (
218 \measure{spreadwidth} - .5*\measure{paperwidth} + \measure{spinewidth},
219 .375*\measure{paperheight}
220 )
221 ;
222
223 StopPage ;
224 \stopuseMPgraphic
225
226 % \starttexdefinition luaextraangle
227 % % we can also just access the last page and so in mp directly
228 % \ctxlua {
229 % context(\lastpage == 0 and 0 or \realfolio*360/\lastpage)
230 % }
231 % \stoptexdefinition
232
233 \startuseMPgraphic{luanumber}
234 % luaextraangle := \luaextraangle;
235 luaextraangle := if (LastPageNumber < 10) : 10 else : (RealPageNumber / LastPageNumber) * 360 fi;
236 luaorbitfactor := 0.25 ;
237 picture p ; p := lualogo ;
238 setbounds p to boundingbox fullcircle ;
239 draw p ysized 1cm ;
240 \stopuseMPgraphic
241
242 \definelayer
243 [page]
244 [width=\paperwidth,
245 height=\paperheight]
246
247 \setupbackgrounds
248 [leftpage]
249 [background=page]
250
251 \setupbackgrounds
252 [rightpage]
253 [background=page]
254
255 \definemeasure[banneroffset][\bottomspace-\footerheight-\footerdistance+2cm]
256
257 \startsetups pagenumber:right
258 \setlayerframed
259 [page]
260 [preset=rightbottom,x=1.0cm,y=\measure{banneroffset}]
261 [frame=off,height=1cm,offset=overlay]
262 {\strut\useMPgraphic{luanumber}}
263 \setlayerframed
264 [page]
265 [preset=rightbottom,x=2.5cm,y=\measure{banneroffset}]
266 [frame=off,height=1cm,width=1cm,offset=overlay,
267 foregroundstyle=bold,foregroundcolor=maincolor]
268 {\strut\pagenumber}
269 \setlayerframed
270 [page]
271 [preset=rightbottom,x=3.5cm,y=\measure{banneroffset}]
272 [frame=off,height=1cm,offset=overlay,
273 foregroundstyle=bold,foregroundcolor=maincolor]
274 {\strut\getmarking[chapter]}
275 \stopsetups
276
277 \startsetups pagenumber:left
278 \setlayerframed
279 [page]
280 [preset=leftbottom,x=3.5cm,y=\measure{banneroffset}]
281 [frame=off,height=1cm,offset=overlay,
282 foregroundstyle=bold,foregroundcolor=maincolor]
283 {\strut\getmarking[chapter]}
284 \setlayerframed
285 [page]
286 [preset=leftbottom,x=2.5cm,y=\measure{banneroffset}]
287 [frame=off,height=1cm,width=1cm,offset=overlay,
288 foregroundstyle=bold,foregroundcolor=maincolor]
289 {\strut\pagenumber}
290 \setlayerframed
291 [page]
292 [preset=leftbottom,x=1.0cm,y=\measure{banneroffset}]
293 [frame=off,height=1cm,offset=overlay]
294 {\strut\useMPgraphic{luanumber}}
295 \stopsetups
296
297 \unexpanded\def\nonterminal#1>{\mathematics{\langle\hbox{\rm #1}\rangle}}
298
299 % taco's brainwave -) .. todo: create a typing variant so that we can avoid the !crlf
300
301 \newcatcodetable\syntaxcodetable
302
303 \unexpanded\def\makesyntaxcodetable
304 {\begingroup
305 \catcode`\<=13 \catcode`\|=12
306 \catcode`\!= 0 \catcode`\\=12
307 \savecatcodetable\syntaxcodetable
308 \endgroup}
309
310 \makesyntaxcodetable
311
312 \unexpanded\def\startsyntax {\begingroup\catcodetable\syntaxcodetable \dostartsyntax}
313 \unexpanded\def\syntax {\begingroup\catcodetable\syntaxcodetable \dosyntax}
314 \let\stopsyntax \relax
315
316 \unexpanded\def\syntaxenvbody#1%
317 {\par
318 \tt
319 \startnarrower
320 % \maincolor
321 #1
322 \stopnarrower
323 \par}
324
325 \unexpanded\def\syntaxbody#1%
326 {\begingroup
327 % \maincolor
328 \tt #1%
329 \endgroup}
330
331 \bgroup \catcodetable\syntaxcodetable
332
333 !gdef!dostartsyntax#1\stopsyntax{!let<!nonterminal!syntaxenvbody{#1}!endgroup}
334 !gdef!dosyntax #1{!let<!nonterminal!syntaxbody{#1}!endgroup}
335
336 !egroup
337
338 \definetyping
339 [texsyntax]
340 % [color=maincolor]
341
342 % end of wave
343
344 \setupinteraction
345 [state=start,
346 focus=standard,
347 style=,
348 color=,
349 contrastcolor=]
350
351 \placebookmarks
352 [chapter,section,subsection]
353
354 \setuplist
355 [chapter,section,subsection,subsubsection]
356 [interaction=all,
357 width=3em]
358
359 \setuplist
360 [chapter]
361 [style=bold,
362 before={\testpage[4]\blank},
363 color=keptcolor]
364
365 \setuplist
366 [section]
367 [before={\testpage[3]}]
368
369 \setuplist
370 [subsection,subsubsection]
371 [margin=3em,
372 width=5em]
373
374 \definestartstop
375 [notabene]
376 [style=slanted]
377
378 \definestartstop
379 [preamble]
380 [style=normal,
381 before=\blank,
382 after=\blank]
383
384 % Hans doesn't like the bookmarks opening by default so we comment this:
385 %
386 % \setupinteractionscreen
387 % [option=bookmark]
388
389 \startbuffer[stylecalculations]
390
391 \normalexpanded{\definemeasure[spinewidth] [0pt]}
392 \normalexpanded{\definemeasure[paperwidth] [\the\paperwidth ]}
393 \normalexpanded{\definemeasure[paperheight][\the\paperheight]}
394 \normalexpanded{\definemeasure[spreadwidth][\measure{paperwidth}]}
395
396 \stopbuffer
397
398 \getbuffer[stylecalculations]
399
400 \dontcomplain
401
402 \environment luatex-logos
403
404 \defineregister[topicindex]
405 \defineregister[primitiveindex]
406 \defineregister[callbackindex]
407 \defineregister[nodeindex]
408 \defineregister[libraryindex]
409
410 \unexpanded\def\lpr#1{\doifmode{*bodypart}{\primitiveindex[#1]{\bf\tex {#1}}}\tex {#1}}
411 \unexpanded\def\prm#1{\doifmode{*bodypart}{\primitiveindex[#1]{\tex {#1}}}\tex {#1}}
412 \unexpanded\def\orm#1{\doifmode{*bodypart}{\primitiveindex[#1]{\tex {#1}}}\tex {#1}}
413 \unexpanded\def\cbk#1{\doifmode{*bodypart}{\callbackindex [#1]{\type {#1}}}\type{#1}}
414 \unexpanded\def\nod#1{\doifmode{*bodypart}{\nodeindex [#1]{\bf\type{#1}}}\type{#1}}
415 \unexpanded\def\whs#1{\doifmode{*bodypart}{\nodeindex [#1]{\type {#1}}}\type{#1}}
416 \unexpanded\def\noa#1{\doifmode{*bodypart}{\nodeindex [#1]{\type {#1}}}\type{#1}}
417
418 \hyphenation{sub-nodes}
419
420 \def\currentlibraryindex{\namedstructureuservariable{section}{library}}
421
422 \setupregister
423 [libraryindex]
424 [indicator=no,before=]
425
426 \setupregister
427 [libraryindex]
428 [1]
429 [textstyle=\ttbf]
430
431 \setupregister
432 [libraryindex]
433 [2]
434 [textstyle=\tttf]
435
436 \unexpanded\def\lib #1{\doifmode{*bodypart}{\expanded{\libraryindex{\currentlibraryindex+#1}}\type{\currentlibraryindex.#1}}}
437 \unexpanded\def\libindex#1{\doifmode{*bodypart}{\expanded{\libraryindex{\currentlibraryindex+#1}}}}
438 \unexpanded\def\libidx#1#2{\doifmode{*bodypart}{\expanded{\libraryindex{#1+#2}}\type{#1.#2}}}
439 \unexpanded\def\lix #1#2{\doifmode{*bodypart}{\expanded{\libraryindex{#1+#2}}}}
440
441 % \setstructurepageregister[][keys:1=,entries:1=]
442
443 \stopenvironment