mtx-context-combine.tex /size: 3104 b    last modification: 2020-07-01 14:35
1
%D \module
2
%D [ file=mtx-context-combine,
3
%D version=2009.03.21,
4
%D title=\CONTEXT\ Extra Trickry,
5
%D subtitle=Combine Files,
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
%D This is a \TEXEXEC\ features that has been moved to \MKIV.
15 16
% begin help
17
%
18
% usage: context --extra=combine [options] list-of-files
19
%
20
% --sort : sort filenames first
21
% --paperoffset=dimension : left-top-offset
22
% --nobanner : no footer etc
23
% --combination : h*v or hxv
24
% --paperformat=spec : paper*print or paperxprint
25
% --nobanner : no footerlines
26
% --bannerheight=dimension : height of banner
27
% --bannerstring=dimension : height of bannerstring
28
%
29
% end help
30 31
\input
mtx
-
context
-
common
.
tex
32 33
\doifdocumentargumentelse
{
paperoffset
}
{
34 35
\setuplayout
36
[
topspace
=
\getdocumentargument
{
paperoffset
}
,
37
backspace
=
\getdocumentargument
{
paperoffset
}
]
38 39
}
{
40 41
\setuplayout
42
[
topspace
=
0
pt
,
43
backspace
=
0
pt
]
44 45
}
46 47
\setuppapersize
48
[
\getdocumentargument
{
paperformat
_
paper
}
]
49
[
\getdocumentargument
{
paperformat
_
print
}
]
50 51
\setuplayout
52
[
header
=
0
pt
,
53
footer
=
0
pt
,
54
width
=
middle
,
55
height
=
middle
]
56 57
\doifnotdocumentargument
{
bannerheight
}
{
58
\setuplayout
59
[
footer
=
1
cm
]
60
}
61 62
\doifelse
{
\getdocumentargument
{
nobanner
}}
{
yes
}
{
63
\setuplayout
64
[
footer
=
0
cm
]
65
\setupbackgrounds
66
[
page
]
67
[
background
=]
68
}
{
69
\definelayer
70
[
page
]
71
[
width
=
\paperwidth
,
72
height
=
\paperheight
]
73 74
\setupbackgrounds
75
[
page
]
76
[
background
=
page
]
77
}
78 79
\setupexternalfigures
80
[
directory
=]
81 82
\starttext
83 84
\startluacode
85
local
format
=
string
.
format
86 87
if
#
document
.
files
>
0
then
88
if
document
.
arguments
[
"
sort
"
]
then
89
table
.
sort
(
document
.
files
)
90
end
91
local
dobanner
=
not
document
.
arguments
[
"
nobanner
"
]
92
local
bannerheight
=
document
.
arguments
[
"
bannerheight
"
]
93
local
nx
=
document
.
arguments
.
combination_nx
or
2
94
local
ny
=
document
.
arguments
.
combination_ny
or
2
95
for
_
,
filename
in
ipairs
(
document
.
files
)
do
96
if
not
string
.
find
(
filename
,
"
^mtx%-context%-
"
)
then
97
-- could be a macro
98
local
bannerstring
=
format
(
"
\\tttf\\detokenize{%s}\\quad\\quad\\currentdate\\quad\\quad\\pagenumber
"
,
file
.
basename
(
filename
)
)
99
if
dobanner
then
100
if
bannerheight
then
101
context
(
"
\\setuptexttexts[{\\setlayerframed[page][preset=middlebottom][frame=off,height=%s]{%s}}]
"
,
bannerheight
,
bannerstring
)
102
else
103
context
(
"
\\setupfootertexts[{%s}]
"
,
bannerstring
)
104
end
105
end
106
context
(
"
\\combinepages[%s][nx=%s,ny=%s]
"
,
filename
,
nx
,
ny
)
107
context
(
"
\\page
"
)
108
end
109
end
110
else
111
context
(
"
no files given
"
)
112
end
113
\stopluacode
114 115
\stoptext
116 117