sinc with TeXLive revision 41284 (trunk).
[luatex.git] / manual / luatex-style.tex
blobfeca120eddb073d907bf945e1505a015efaa7b0d
1 \startenvironment luatex-style
3 \usemodule[abr-02]
5 \setuplayout
6 [height=middle,
7 width=middle,
8 backspace=2cm,
9 topspace=10mm,
10 bottomspace=10mm,
11 header=10mm,
12 footer=10mm,
13 footerdistance=10mm,
14 headerdistance=10mm]
16 \setuppagenumbering
17 [alternative=doublesided]
19 \setuptolerance
20 [stretch,tolerant]
22 \setuptype
23 [lines=hyphenated]
25 \setuptyping
26 [lines=hyphenated]
28 \setupitemize
29 [each]
30 [packed]
32 \setupwhitespace
33 [medium]
35 \startluacode
36 local skipped = table.tohash { 'id', 'subtype', 'next', 'prev' }
38 function document.functions.showfields(s)
39 local t = string.split(s,',')
40 local f = node.fields(t[1],t[2])
41 if f then
42 local d = false
43 for i=1,#f do
44 local fi = f[i]
45 if skipped[fi] then
46 -- okay
47 elseif d then
48 context(', {\tttf %s}', fi)
49 else
50 context('{\tttf %s}', fi)
51 d = true
52 end
53 end
54 end
55 end
57 function document.functions.showid(s)
58 local t = string.split(s,',')
59 context('{tttf %s}',node.id(t[1]))
60 if t[2] then
61 context(', {tttf %s}',node.subtype(t[2]))
62 end
63 end
65 function document.functions.showsubtypes(s)
66 local s = node.subtypes(s)
67 local d = false
68 for k, v in table.sortedhash(s) do
69 if d then
70 context(', %s = {\\tttf %s}',k,v)
71 else
72 context('%s = {\\tttf %s}',k,v)
73 d = true
74 end
75 end
76 end
77 \stopluacode
79 \unexpanded\def\showfields #1{\ctxlua{document.functions.showfields("#1")}}
80 \unexpanded\def\showid #1{\ctxlua{document.functions.showid("#1")}}
81 \unexpanded\def\showsubtypes#1{\ctxlua{document.functions.showsubtypes("#1")}}
83 \definecolor[blue] [b=.5]
84 \definecolor[red] [r=.5]
85 \definecolor[green] [g=.5]
86 \definecolor[maincolor] [b=.5]
87 \definecolor[keptcolor] [b=.5]
88 \definecolor[othercolor][r=.5,g=.5]
90 \setupbodyfont[modern] % we need this in examples so we predefine
92 % \doifmodeelse {atpragma} {
94 % % \setupbodyfont
95 % % [lucidaot,10pt]
97 % \setupbodyfont
98 % [dejavu,10pt]
100 % \setuphead [chapter] [style=\bfd]
101 % \setuphead [section] [style=\bfb]
102 % \setuphead [subsection] [style=\bfa]
103 % \setuphead [subsubsection][style=\bf]
105 % } {
107 % \definetypeface[mainfacenormal] [ss][sans] [iwona] [default]
108 % \definetypeface[mainfacenormal] [rm][serif][palatino] [default]
109 % \definetypeface[mainfacenormal] [tt][mono] [modern] [default][rscale=1.1]
110 % \definetypeface[mainfacenormal] [mm][math] [iwona] [default]
112 % \definetypeface[mainfacemedium] [ss][sans] [iwona-medium][default]
113 % \definetypeface[mainfacemedium] [rm][serif][palatino] [default]
114 % \definetypeface[mainfacemedium] [tt][mono] [modern] [default][rscale=1.1]
115 % \definetypeface[mainfacemedium] [mm][math] [iwona-medium][default]
117 % \setupbodyfont
118 % [mainfacenormal,10pt]
120 % \setuphead [chapter] [style=\mainfacemedium\bfd]
121 % \setuphead [section] [style=\mainfacemedium\bfb]
122 % \setuphead [subsection] [style=\mainfacemedium\bfa]
123 % \setuphead [subsubsection][style=\mainfacemedium\bf]
127 \writestatus{luatex manual}{we assume that dejavu math is available}
129 \setupbodyfont % assumes dejavu-math
130 [dejavu,10pt]
132 \setuphead [chapter] [align={flushleft,broad},style=\bfd]
133 \setuphead [section] [align={flushleft,broad},style=\bfb]
134 \setuphead [subsection] [align={flushleft,broad},style=\bfa]
135 \setuphead [subsubsection][align={flushleft,broad},style=\bf]
137 \setuphead [chapter] [color=maincolor]
138 \setuphead [section] [color=maincolor]
139 \setuphead [subsection] [color=maincolor]
140 \setuphead [subsubsection][color=maincolor]
142 \definehead
143 [remark]
144 [subsubsubject]
146 \setupheadertexts
149 \definemixedcolumns
150 [twocolumns]
151 [n=2,
152 balance=yes,
153 before=\blank,
154 after=\blank]
156 \definemixedcolumns
157 [threecolumns]
158 [twocolumns]
159 [n=3]
161 \definemixedcolumns
162 [fourcolumns]
163 [threecolumns]
164 [n=4]
166 % if we do this we also need to do it in table cells
168 % \setuptyping
169 % [color=maincolor]
171 % \setuptype
172 % [color=maincolor]
174 \definetyping
175 [functioncall]
177 \startMPdefinitions
179 color luaplanetcolor ; luaplanetcolor := \MPcolor{maincolor} ;
180 color luaholecolor ; luaholecolor := white ;
181 numeric luaextraangle ; luaextraangle := 0 ;
182 numeric luaorbitfactor ; luaorbitfactor := .25 ;
184 vardef lualogo = image (
186 % Graphic design by A. Nakonechnyj. Copyright (c) 1998, All rights reserved.
188 save d, r, p ; numeric d, r, p ;
190 d := sqrt(2)/4 ; r := 1/4 ; p := r/8 ;
192 fill fullcircle scaled 1
193 withcolor luaplanetcolor ;
194 draw fullcircle rotated 40.5 scaled (1+r)
195 dashed evenly scaled p
196 withpen pencircle scaled (p/2)
197 withcolor (luaorbitfactor * luaholecolor) ;
198 fill fullcircle scaled r shifted (d+1/8,d+1/8)
199 rotated luaextraangle
200 withcolor luaplanetcolor ;
201 fill fullcircle scaled r shifted (d-1/8,d-1/8)
202 withcolor luaholecolor ;
203 luaorbitfactor := .25 ;
204 ) enddef ;
206 \stopMPdefinitions
208 \startuseMPgraphic{luapage}
209 StartPage ;
211 fill Page withcolor \MPcolor{othercolor} ;
213 luaorbitfactor := 1 ;
214 picture p ; p := lualogo xsized (3PaperWidth/5) ;
215 draw p shifted center Page shifted (0,-.5ypart center ulcorner p) ;
217 StopPage ;
218 \stopuseMPgraphic
220 \starttexdefinition luaextraangle
221 % we can also just access the last page and so in mp directly
222 \ctxlua {
223 context(\lastpage == 0 and 0 or \realfolio*360/\lastpage)
225 \stoptexdefinition
227 \startuseMPgraphic{luanumber}
228 luaextraangle := \luaextraangle;
229 luaorbitfactor := 0.25 ;
230 picture p ; p := lualogo ;
231 setbounds p to boundingbox fullcircle ;
232 draw p ysized 1cm ;
233 \stopuseMPgraphic
235 \definelayer
236 [page]
237 [width=\paperwidth,
238 height=\paperheight]
240 \setupbackgrounds
241 [leftpage]
242 [background=page]
244 \setupbackgrounds
245 [rightpage]
246 [background=page]
248 \startsetups pagenumber:right
249 \setlayerframed
250 [page]
251 [preset=rightbottom,offset=1cm]
252 [frame=off,height=1cm,offset=overlay]
253 {\useMPgraphic{luanumber}}
254 \setlayerframed
255 [page]
256 [preset=rightbottom,offset=1cm,x=1.5cm]
257 [frame=off,height=1cm,width=1cm,offset=overlay]
258 {\pagenumber}
259 \setlayerframed
260 [page]
261 [preset=rightbottom,offset=1cm,x=2.5cm]
262 [frame=off,height=1cm,offset=overlay]
263 {\getmarking[chapter]}
264 \stopsetups
266 \startsetups pagenumber:left
267 \setlayerframed
268 [page]
269 [preset=leftbottom,offset=1cm,x=2.5cm]
270 [frame=off,height=1cm,offset=overlay]
271 {\getmarking[chapter]}
272 \setlayerframed
273 [page]
274 [preset=leftbottom,offset=1cm,x=1.5cm]
275 [frame=off,height=1cm,width=1cm,offset=overlay]
276 {\pagenumber}
277 \setlayerframed
278 [page]
279 [preset=leftbottom,offset=1cm]
280 [frame=off,height=1cm,offset=overlay]
281 {\useMPgraphic{luanumber}}
282 \stopsetups
284 \unexpanded\def\nonterminal#1>{\mathematics{\langle\hbox{\rm #1}\rangle}}
286 % taco's brainwave -)
288 \newcatcodetable\syntaxcodetable
290 \unexpanded\def\makesyntaxcodetable
291 {\begingroup
292 \catcode`\<=13 \catcode`\|=12
293 \catcode`\!= 0 \catcode`\\=12
294 \savecatcodetable\syntaxcodetable
295 \endgroup}
297 \makesyntaxcodetable
299 \unexpanded\def\startsyntax {\begingroup\catcodetable\syntaxcodetable \dostartsyntax}
300 \unexpanded\def\syntax {\begingroup\catcodetable\syntaxcodetable \dosyntax}
301 \let\stopsyntax \relax
303 \unexpanded\def\syntaxenvbody#1%
304 {\par
306 \startnarrower
307 \maincolor #1
308 \stopnarrower
309 \par}
311 \unexpanded\def\syntaxbody#1%
312 {\begingroup
313 \maincolor \tt #1%
314 \endgroup}
316 \bgroup \catcodetable\syntaxcodetable
318 !gdef!dostartsyntax#1\stopsyntax{!let<!nonterminal!syntaxenvbody{#1}!endgroup}
319 !gdef!dosyntax #1{!let<!nonterminal!syntaxbody{#1}!endgroup}
321 !egroup
323 % end of wave
325 \setupinteraction
326 [state=start,
327 focus=standard,
328 style=,
329 color=,
330 contrastcolor=]
332 \placebookmarks
333 [chapter,section,subsection]
335 \setuplist
336 [chapter,section,subsection,subsubsection]
337 [interaction=all,
338 width=3em]
340 \setuplist
341 [chapter]
342 [style=bold,
343 color=keptcolor]
345 \setuplist
346 [subsection,subsubsection]
347 [margin=3em,
348 width=5em]
350 % Hans doesn't like the bookmarks opening by default so we comment this:
352 % \setupinteractionscreen
353 % [option=bookmark]
355 \stopenvironment