mtx-context-common.tex /size: 1328 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=mtx-context-common,
3
%D version=2009.03.21,
4
%D title=\CONTEXT\ Extra Trickry,
5
%D subtitle=Common Stuff,
6
%D author=Hans Hagen,
7
%D date=\currentdate,
8
%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9
%C
10
%C This module is part of the \CONTEXT\ macro||package and is
11
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12
%C details.
13 14
\startluacode
15
local
combination
=
document
.
arguments
[
'
combination
'
]
or
'
2*2
'
16
local
nx
,
ny
=
string
.
match
(
combination
,
"
^(%d+)%s*[%*x]%s*(%d+)$
"
)
17
if
not
nx
then
18
nx
,
ny
=
2
,
2
19
elseif
not
ny
then
20
nx
=
tonumber
(
combination
)
or
2
21
ny
=
nx
22
else
23
nx
=
tonumber
(
nx
)
or
2
24
ny
=
tonumber
(
ny
)
or
nx
or
2
25
end
26
document
.
setargument
(
"
combination_nx
"
,
nx
)
27
document
.
setargument
(
"
combination_ny
"
,
ny
)
28
\stopluacode
29 30
\startluacode
31
local
paperformat
=
document
.
arguments
[
'
paperformat
'
]
or
'
A4*A4
'
32
-- paperformat = string.upper(paperformat) -- no, as we don't want to uppercase 'landscape'
33
local
f
,
t
=
string
.
match
(
paperformat
,
"
^(.-)%s*[%*xX]%s*(.-)$
"
)
34
if
not
f
then
35
f
,
t
=
"
A4
"
,
"
A4
"
36
elseif
not
t
then
37
t
=
f
38
end
39
document
.
setargument
(
"
paperformat_paper
"
,
f
)
40
document
.
setargument
(
"
paperformat_print
"
,
t
)
41
\stopluacode
42 43
\endinput
44