1\starttexdefinition OneMathSample #1#2
2 \startcontent
3 \switchtobodyfont[#1]
4 \framed[align=middle,offset=2ex,corner=round,rulethickness=1pt,framecolor=darkred] \bgroup
5 \getbuffer[#2]
6 \blank[back]
7 \egroup
8 \stopcontent
9 \startcaption
10 \tt\tfb\color[darkred]{#1}
11 \stopcaption
12\stoptexdefinition
13
14\startluacode
15 local default = {
16 "cambria",
17 "modern",
18
19 "dejavu",
20 "pagella",
21 "termes",
22 "bonum",
23 "schola",
24 "lucidadk",
25
26 "stixtwo",
27 "libertinus",
28 "ebgaramond",
29 "kpfonts",
30
31
32 }
33
34 function document.MathSamples(list,samples)
35 list = string.strip(list)
36 samples = string.strip(samples)
37 local s = list ~= "" and utilities.parsers.settings_to_array(list) or default
38 local n = #s
39 if s[n] == "" then
40 n = n - 1
41 end
42 local m = n % 4
43 local x = 4
44 local y = n // 4
45 if m > 0 then
46 x = x + 1
47 end
48
49
50
51
52 context.startcombination { nx = x, ny = y, location = "top", distance = "2ex", after = "\\blank[2*big]" }
53 for i=1,n do
54 context.OneMathSample(s[i],samples)
55 end
56 context.stopcombination()
57
58 end
59\stopluacode
60
61\protected\def\MathSamples[#1]#*[#2]
62 {\ctxlua{document.MathSamples("#1","#2")}}
63
64\def\DoShowNextBox
65 {\begingroup
66 \dowithnextbox
67 {\showboxinbuffer{mathbox}\nextbox\plusone
68 \midaligned{\framed{\box\nextbox}}
69 \switchtobodyfont[4pt]
70 \typebuffer[mathbox][option=TEX]
71 \endgroup
72 \endgroup}
73 \hbox}
74
75\protected\def\StartShowBox
76 {\begingroup
77 \protected\def\StopShowBox{\removeunwantedspaces\egroup}
78 \DoShowNextBox
79 \bgroup\ignorespaces}
80
81\protected\def\ShowBox
82 {\begingroup
83 \DoShowNextBox}
84 |