1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34\input mtx context common . tex
35
36\doifdocumentargument { paperoffset } {
37 \definepapersize
38 [ offset = \getdocumentargumentdefault { paperoffset }{ 0 pt } ]
39}
40
41\doifdocumentargumentelse { noduplex } {
42 \setuppagenumbering
43 [ alternative = doublesided ]
44 \setdocumentargument { sided }{ doublesided }
45} {
46 \setdocumentargument { sided }{ singlesided }
47}
48
49
50\setuppapersize
51 [ \getdocumentargument { paperformat paper } ]
52 [ \getdocumentargument { paperformat print } ]
53
54
55
56
57
58
59
60\setdocumentargumentdefault { textwidth } { 0 cm }
61\setdocumentargumentdefault { backspace } { 0 cm }
62\setdocumentargumentdefault { topspace } { 0 cm }
63
64\setuplayout
65 [ backspace = \getdocumentargument { backspace } ,
66 topspace = \getdocumentargument { topspace } ,
67 width = middle ,
68 height = middle ,
69 location = middle ,
70 header = 0 pt ,
71 footer = 0 pt ]
72
73\doifdocumentargument { marking } { yes } {
74 \setuplayout
75 [ marking = on ]
76}
77
78\startluacode
79 local printformat = document . arguments . printformat or " "
80 if printformat = = " " then
81 printformat = " normal "
82 elseif string . find ( printformat , " xy " ) then
83 if false then
84 context . setuplayout {
85 nx = document . arguments . nx or 1 ,
86 ny = document . arguments . ny or 1 ,
87 }
88 printformat = " XY,\\v!rotated "
89 else
90 context . setuppaper {
91 nx = document . arguments . nx or 1 ,
92 ny = document . arguments . ny or 1 ,
93 }
94 printformat = " XY "
95 end
96 elseif string . find ( printformat , " .*up " ) then
97 printformat = " 2UP,\\v!rotated "
98 elseif string . find ( printformat , " .*down " ) then
99 printformat = " 2DOWN,\\v!rotated "
100 elseif string . find ( printformat , " .*side " ) then
101 printformat = " 2SIDE,\\v!rotated "
102 end
103 document . setargument ( " printformat " , printformat )
104\stopluacode
105
106\setuparranging
107 [ \getdocumentargument { sided } ,
108 \getdocumentargument { printformat } ]
109
110\starttext
111
112\startluacode
113 local arguments = document . arguments
114 local files = document . files
115 local noffiles = # files
116 if noffiles > 0 then
117 if arguments . sort then
118 table . sort ( files )
119 end
120 local emptypages = arguments . addempty or " "
121 local textwidth = arguments . textwidth or " 0cm "
122 for i = 1 , noffiles do
123 local filename = files [ i ]
124 if not string . find ( file . basename ( filename ) , " ^mtx%-context%- " ) then
125 context . insertpages (
126 { filename } ,
127 { emptypages } ,
128 { width = textwidth }
129 )
130 end
131 end
132 else
133 context ( " no files given " )
134 end
135\stopluacode
136
137\stoptext
138 |