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
35
36
37
38
39
40
41
42
43
|
%D \module
%D [ file=mtx-context-common,
%D version=2009.03.21,
%D title=\CONTEXT\ Extra Trickry,
%D subtitle=Common Stuff,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright=\PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\startluacode
local combination = document.arguments['combination'] or '2*2'
local nx, ny = string.match(combination,"^(%d+)%s*[%*x]%s*(%d+)$")
if not nx then
nx, ny = 2, 2
elseif not ny then
nx = tonumber(combination) or 2
ny = nx
else
nx = tonumber(nx) or 2
ny = tonumber(ny) or nx or 2
end
document.setargument("combination_nx",nx)
document.setargument("combination_ny",ny)
\stopluacode
\startluacode
local paperformat = document.arguments['paperformat'] or 'A4*A4'
paperformat = string.upper(paperformat)
local f, t = string.match(paperformat,"^(.-)%s*[%*xX]%s*(.-)$")
if not f then
f, t = "A4", "A4"
elseif not t then
t = f
end
document.setargument("paperformat_paper",f)
document.setargument("paperformat_print",t)
\stopluacode
\endinput
|