1
2
3\startenvironment luametatexstyle
4
5
6
7
8
9
10
11\enabletrackers[fonts.usage]
12
13\usemodule[fontsstatistics]
14
15\setuplayout
16 [height=middle,
17 width=middle,
18 backspace=2cm,
19 topspace=10mm,
20 bottomspace=10mm,
21 header=10mm,
22 footer=10mm,
23 footerdistance=10mm,
24 headerdistance=10mm]
25
26\setuppagenumbering
27 [alternative=doublesided]
28
29\setuptolerance
30 [stretch,tolerant]
31
32\setuptype
33 [lines=hyphenated]
34
35\setuptyping
36 [lines=hyphenated]
37
38\setupitemize
39 [each]
40 [packed]
41
42\definesymbol[1][\tocharacter"2023]
43\definesymbol[2][\endash]
44\definesymbol[3][\wait]
45
46\setupitemize
47 [each]
48 [headcolor=maincolor,
49 symbolcolor=maincolor,
50 color=maincolor]
51
52\setupwhitespace
53 [medium]
54
55\setuptabulate
56 [blank={small,samepage},
57 margin=.25em,
58 headstyle=bold,
59 rulecolor=maincolor,
60 rulethickness=1pt,
61 foregroundcolor=white,
62 foregroundstyle=\ss\bfx\WORD,
63 backgroundcolor=maincolor]
64
65\setupcaptions
66 [headcolor=darkblue]
67
68\startluacode
69 local skipped = { 'id', 'subtype', 'next', 'prev' }
70
71 local function showlist(l,skipped)
72 if l then
73 l = table.tohash(l)
74 if skipped then
75 for i=1,#skipped do
76 l[skipped[i]] = nil
77 end
78 end
79 l = table.sortedkeys(l)
80 local n = #l
81 for i=1,n do
82 context("%s{\\tttf %s}", (i == 1 and "") or (i == n and " and ") or ", ", l[i])
83 end
84 end
85 end
86
87 function document.functions.showvalues(l,hex)
88 if l then
89 local n = table.count(l)
90 local i = 0
91 local f = hex and "%s{\\tttf %s} (0x%02X)" or "%s{\\tttf %s} (%i)"
92 for k, v in table.sortedhash(l) do
93 i = i + 1
94 context(f, (i == 1 and "") or (i == n and " and ") or ", ", v,k)
95 end
96 end
97 end
98
99 function document.functions.showfields(s)
100 local t = string.split(s,',')
101 showlist(node.fields(t[1],t[2]),skipped)
102 end
103
104 function document.functions.showid(s)
105 local t = string.split(s,',')
106 local i = t[1] and node.id(t[1])
107 local s = t[2] and node.subtype(t[2])
108 if s then
109 context('{\\tttf %s}, {\\tttf %s}',i,s)
110 else
111 context('{\\tttf %s}',i)
112 end
113 end
114
115 function document.functions.showsubtypes(s)
116 showlist(node.subtypes(s))
117 end
118
119\stopluacode
120
121\protected\def\showfields #1{\ctxlua{document.functions.showfields("#1")}}
122\protected\def\showid #1{\ctxlua{document.functions.showid("#1")}}
123\protected\def\showsubtypes #1{\ctxlua{document.functions.showsubtypes("#1")}}
124\protected\def\showvalues #1{\ctxlua{document.functions.showvalues(tex.get#1values())}}
125\protected\def\showhexvalues#1{\ctxlua{document.functions.showvalues(tex.get#1values(),true)}}
126\protected\def\showtypes {\ctxlua{document.functions.showvalues(node.types())}}
127\protected\def\showvaluelist#1{\ctxlua{document.functions.showvalues(#1)}}
128
129\definecolor[blue] [b=.5]
130\definecolor[red] [r=.5]
131\definecolor[green] [g=.5]
132
133
134
135
136\definecolor[maincolor] [b=.5]
137\definecolor[mooncolor] [b=.5]
138\definecolor[keptcolor] [b=.5]
139
140\definecolor[othercolor][r=.5,g=.5]
141
142\writestatus{luametatex manual}{}
143\writestatus{luametatex manual}{defining lucidaot} \usebodyfont [lucidaot]
144\writestatus{luametatex manual}{defining pagella} \usebodyfont [pagella]
145\writestatus{luametatex manual}{defining cambria} \usebodyfont [cambria]
146\writestatus{luametatex manual}{defining modern} \usebodyfont [modern]
147\writestatus{luametatex manual}{defining dejavu} \setupbodyfont[dejavu,10pt]
148\writestatus{luametatex manual}{}
149
150\setuphead [chapter] [align={flushleft,broad},style=\bfd]
151\setuphead [section] [align={flushleft,broad},style=\bfb]
152\setuphead [subsection] [align={flushleft,broad},style=\bfa]
153\setuphead [subsubsection][align={flushleft,broad},style=\bf,after=\blank,before=\blank]
154
155\setuphead [chapter] [color=maincolor]
156\setuphead [section] [color=maincolor]
157\setuphead [subsection] [color=maincolor]
158\setuphead [subsubsection][color=maincolor]
159
160\setupfloats
161 [ntop=4]
162
163\definehead
164 [remark]
165 [subsubsubject]
166
167\setupheadertexts
168 []
169
170
171
172
173
174\definemixedcolumns
175 [twocolumns]
176 [n=2,
177 balance=yes,
178 before=\blank,
179 after=\blank]
180
181\definemixedcolumns
182 [threecolumns]
183 [twocolumns]
184 [n=3]
185
186\definemixedcolumns
187 [fourcolumns]
188 [threecolumns]
189 [n=4]
190
191
192
193
194
195
196
197
198
199\definetyping
200 [functioncall]
201
202\startMPdefinitions
203
204 string luaplanetcolor ; luaplanetcolor := "maincolor" ;
205 string luamooncolor ; luaplanetcolor := "mooncolor" ;
206 string luaholecolor ; luaholecolor := "white" ;
207 string luaorbitcolor ; luaorbitcolor := "darkgray" ;
208 numeric luaextraangle ; luaextraangle := 0 ;
209
210 vardef lualogo = image (
211
212
213
214 save d, r, p ; numeric d, r, p ;
215
216 d := sqrt(2)4 ; r := 14 ; p := r8 ;
217
218 fill fullcircle scaled 1
219 withcolor luaplanetcolor ;
220 draw fullcircle rotated 40.5 scaled (1r)
221 dashed evenly scaled p
222 withpen pencircle scaled (p2)
223 withcolor luaorbitcolor ;
224 fill fullcircle scaled r shifted (d+18,d+18)
225 rotated luaextraangle
226 withcolor luamooncolor ;
227 fill fullcircle scaled r shifted (d-18,d-18)
228 withcolor luaholecolor ;
229 luaorbitfactor := .25 ;
230 ) enddef ;
231
232\stopMPdefinitions
233
234\startuseMPgraphic{luapage}
235 StartPage ;
236
237 fill Page withcolor \MPcolor{othercolor} ;
238
239 luaorbitcolor := "white" ;
240 luamooncolor := "maincolor" ;
241
242 picture p ; p := lualogo ysized (5\measure{paperheight}10) ;
243 draw p
244 shifted center p
245 shifted (
246 \measure{spreadwidth} .5\measure{paperwidth} \measure{spinewidth},
247 .375\measure{paperheight}
248 )
249 ;
250
251 StopPage ;
252\stopuseMPgraphic
253
254
255
256
257
258
259
260
261\startuseMPgraphic{luanumber}
262
263 luaextraangle := if (LastPageNumber < 10) : 10 else : (RealPageNumber LastPageNumber) 360 fi;
264 luaorbitcolor := "darkgray" ;
265 luamooncolor := "othercolor" ;
266
267 picture p ; p := lualogo ;
268 setbounds p to boundingbox fullcircle ;
269 draw p ysized 1cm ;
270\stopuseMPgraphic
271
272\definelayer
273 [page]
274 [width=\paperwidth,
275 height=\paperheight]
276
277\setupbackgrounds
278 [leftpage]
279 [background=page]
280
281\setupbackgrounds
282 [rightpage]
283 [background=page]
284
285\definemeasure[banneroffset][\bottomspace\footerheight\footerdistance2cm]
286
287\startsetups pagenumber:right
288 \setlayerframed
289 [page]
290 [preset=rightbottom,x=1.0cm,y=\measure{banneroffset}]
291 [frame=off,height=1cm,offset=overlay]
292 {\strut\useMPgraphic{luanumber}}
293 \setlayerframed
294 [page]
295 [preset=rightbottom,x=2.5cm,y=\measure{banneroffset}]
296 [frame=off,height=1cm,width=1cm,offset=overlay,
297 foregroundstyle=bold,foregroundcolor=maincolor]
298 {\strut\pagenumber}
299 \setlayerframed
300 [page]
301 [preset=rightbottom,x=3.5cm,y=\measure{banneroffset}]
302 [frame=off,height=1cm,offset=overlay,
303 foregroundstyle=bold,foregroundcolor=maincolor]
304 {\strut\getmarking[chapter]}
305\stopsetups
306
307\startsetups pagenumber:left
308 \setlayerframed
309 [page]
310 [preset=leftbottom,x=3.5cm,y=\measure{banneroffset}]
311 [frame=off,height=1cm,offset=overlay,
312 foregroundstyle=bold,foregroundcolor=maincolor]
313 {\strut\getmarking[chapter]}
314 \setlayerframed
315 [page]
316 [preset=leftbottom,x=2.5cm,y=\measure{banneroffset}]
317 [frame=off,height=1cm,width=1cm,offset=overlay,
318 foregroundstyle=bold,foregroundcolor=maincolor]
319 {\strut\pagenumber}
320 \setlayerframed
321 [page]
322 [preset=leftbottom,x=1.0cm,y=\measure{banneroffset}]
323 [frame=off,height=1cm,offset=overlay]
324 {\strut\useMPgraphic{luanumber}}
325\stopsetups
326
327\protected\def\nonterminal#1>{\mathematics{\langle\hbox{\rm #1}\rangle}}
328
329
330
331\newcatcodetable\syntaxcodetable
332
333\protected\def\makesyntaxcodetable
334 {\begingroup
335 \catcode\<=13 \catcode\|=12
336 \catcode\!= 0 \catcode\\=12
337 \savecatcodetable\syntaxcodetable
338 \endgroup}
339
340\makesyntaxcodetable
341
342\protected\def\startsyntax {\begingroup\catcodetable\syntaxcodetable \dostartsyntax}
343\protected\def\syntax {\begingroup\catcodetable\syntaxcodetable \dosyntax}
344 \let\stopsyntax \relax
345
346\protected\def\syntaxenvbody#1
347 {\par
348 \tt
349 \startnarrower
350
351 #1
352 \stopnarrower
353 \par}
354
355\protected\def\syntaxbody#1
356 {\begingroup
357
358 \tt #1
359 \endgroup}
360
361\bgroup \catcodetable\syntaxcodetable
362
363!gdef!dostartsyntax#1\stopsyntax{!let<!nonterminal!syntaxenvbody{#1}!endgroup}
364!gdef!dosyntax #1{!let<!nonterminal!syntaxbody{#1}!endgroup}
365
366!egroup
367
368\definetyping
369 [texsyntax]
370
371
372
373
374\setupinteraction
375 [state=start,
376 focus=standard,
377 style=,
378 color=,
379 contrastcolor=]
380
381\placebookmarks
382 [chapter,section,subsection]
383
384\setuplist
385 [chapter,section,subsection,subsubsection]
386 [interaction=all,
387 width=4em]
388
389\setuplist
390 [chapter]
391 [style=bold,
392 color=keptcolor]
393
394\setuplist
395 [chapter]
396 [before={\testpage[4]\blank},
397
398 after={\blank[samepage]}]
399
400
401
402
403
404\setuplist
405 [section,subsection]
406 [before={\ifnum \structurelistrawnumber{section}=1 \blank[samepage] \fi}]
407
408\setuplist
409 [subsection,subsubsection]
410 [margin=4em,
411 width=5em]
412
413\definestartstop
414 [notabene]
415 [style=slanted]
416
417\definestartstop
418 [preamble]
419 [style=normal,
420 before=\blank,
421 after=\blank]
422
423
424
425
426
427
428\startbuffer[stylecalculations]
429
430 \normalexpanded{\definemeasure[spinewidth] [0pt]}
431 \normalexpanded{\definemeasure[paperwidth] [\the\paperwidth ]}
432 \normalexpanded{\definemeasure[paperheight][\the\paperheight]}
433 \normalexpanded{\definemeasure[spreadwidth][\measure{paperwidth}]}
434
435\stopbuffer
436
437\getbuffer[stylecalculations]
438
439\dontcomplain
440
441
442\usemodule[abbreviationslogos]
443
444\defineregister[topicindex]
445\defineregister[luatexindex]
446\defineregister[etexindex]
447\defineregister[texindex]
448\defineregister[primitiveindex]
449\defineregister[callbackindex]
450\defineregister[nodeindex]
451\defineregister[libraryindex]
452
453\setupregister[etexindex] [textstyle=bold]
454\setupregister[luatexindex][textstyle=bold]
455
456
457
458\protected\def\cbk#1{\doifmode{*bodypart}{\callbackindex [#1]{\type {#1}}}\type{#1}}
459\protected\def\nod#1{\doifmode{*bodypart}{\nodeindex [#1]{\bf\type{#1}}}\type{#1}}
460\protected\def\whs#1{\doifmode{*bodypart}{\nodeindex [#1]{\type {#1}}}\type{#1}}
461\protected\def\noa#1{\doifmode{*bodypart}{\nodeindex [#1]{\type {#1}}}\type{#1}}
462
463\protected\def\prm#1{\doifmode{*bodypart}{\getvalue{\ctxlua{document.primitiveorigin("#1")}index}{\tex{#1}}}\tex{#1}}
464
465\hyphenation{subnodes}
466
467\def\currentlibraryindex{\namedstructureuservariable{section}{library}}
468
469\setupregister
470 [alternative=a,
471 balance=no]
472
473\setupregister
474 [libraryindex]
475 [indicator=no,before=]
476
477\setupregister
478 [libraryindex]
479 [1]
480 [textstyle=\ttbf]
481
482\setupregister
483 [libraryindex]
484 [2]
485 [textstyle=\tttf]
486
487\protected\def\lib #1{\doifmode{*bodypart}{\expanded{\libraryindex{\currentlibraryindex#1}}}\type{\currentlibraryindex.#1}}
488\protected\def\libindex#1{\doifmode{*bodypart}{\expanded{\libraryindex{\currentlibraryindex#1}}}}
489\protected\def\libidx#1#2{\doifmode{*bodypart}{\expanded{\libraryindex{#1#2}}\type{#1.#2}}}
490\protected\def\lix #1#2{\doifmode{*bodypart}{\expanded{\libraryindex{#1#2}}}}
491
492
493
494\protected\def\inlineluavalue#1
495 {{\maincolor \ctxlua {
496 local t = #1
497 if type(t) == "table" then
498 t = string.gsub(table.serialize(t,false),"="," = ")
499 else
500 t = tostring(t)
501 end
502 context.typ(t)
503 }}}
504
505
506
507
508
509
510\startluacode
511local list = token.getprimitives()
512local origins = tex.getprimitiveorigins()
513local hash = { }
514
515for i=1,#list do
516 local l = list[i]
517 hash[l[3]] = l
518end
519
520
521
522function document.primitiveorigin(name)
523 local h = hash[name]
524 if h then
525 context(origins[h[4]])
526 else
527 logs.report("!!!!!!","unknown primitive %s",name)
528 context("tex")
529 end
530end
531
532function document.showprimitives(tag)
533 local t = tex.extraprimitives(tag)
534 table.sort(t)
535 for i=1,#t do
536 local v = t[i]
537 if v ~= ' ' and v ~= "/" and v ~= "-" then
538 context.type(v)
539 context.space()
540 end
541 end
542end
543
544
545
546function document.filteredprimitives(cmd)
547 local t = { }
548 local c = tokens.commands[cmd]
549 for i=1,#list do
550 local l = list[i]
551 if l[1] == c then
552 t[#t+1] = l[3]
553 end
554 end
555 table.sort(t)
556 for i=1,#t do
557 if i > 1 then
558 context(", ")
559 elseif i == #t then
560 context(" and ")
561 end
562 context.typ(t[i])
563 end
564end
565
566function document.allprimitives()
567 local c = tokens.commands
568 local o = origins
569 table.sort(list, function(a,b)
570 return a[3] < b[3]
571 end)
572 context.starttabulate { "|T|T|Tr|Tr|T|" }
573 context.DB() context("primitive")
574 context.BC() context("command name")
575 context.BC() context("cmd")
576 context.BC() context("chr")
577 context.BC() context("origin")
578 context.NC() context.NR()
579 context.TB()
580 for i=1,#list do
581 local l = list[i]
582 context.NC() context.tex(l[3])
583 context.NC() context(c[l[1]])
584 context.NC() context(l[1])
585 context.NC() context(l[2])
586 context.NC() context(o[l[4]])
587 context.NC() context.NR()
588 end
589 context.LL()
590 context.stoptabulate()
591end
592\stopluacode
593
594\stopenvironment
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657 |