summaryrefslogtreecommitdiff
path: root/tex/context/base/mtx-context-arrange.tex
diff options
context:
space:
mode:
authorMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
committerMarius <mariausol@gmail.com>2010-07-04 15:32:09 +0300
commit85b7bc695629926641c7cb752fd478adfdf374f3 (patch)
tree80293f5aaa7b95a500a78392c39688d8ee7a32fc /tex/context/base/mtx-context-arrange.tex
downloadcontext-85b7bc695629926641c7cb752fd478adfdf374f3.tar.gz
stable 2010-05-24 13:10
Diffstat (limited to 'tex/context/base/mtx-context-arrange.tex')
-rw-r--r--tex/context/base/mtx-context-arrange.tex111
1 files changed, 111 insertions, 0 deletions
diff --git a/tex/context/base/mtx-context-arrange.tex b/tex/context/base/mtx-context-arrange.tex
new file mode 100644
index 000000000..73431567d
--- /dev/null
+++ b/tex/context/base/mtx-context-arrange.tex
@@ -0,0 +1,111 @@
+% engine=luatex
+
+%D \module
+%D [ file=mtx-context-arrange,
+%D version=2009.03.21,
+%D title=\CONTEXT\ Extra Trickry,
+%D subtitle=Arrange Files,
+%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.
+
+%D This is a \TEXEXEC\ features that has been moved to \MKIV.
+
+% begin help
+%
+% usage: context --extra=arrange [options] list-of-files
+%
+% --sort : sort filenames first
+% --paperoffset=dimension : left-top-offset
+% --noduplex : singlesided (doublesided is default)
+% --backspace=dimension : extra left offset
+% --topspace=dimension : extra top offset
+% --marking : add cutmarks
+% --addempty=list : add empty pages at/after (comma separated list)
+% --printformat : 2UP, etc
+%
+% end help
+
+\doifdocumentargument {paperoffset} {
+ \definepapersize
+ [offset=\getdocumentargument{paperoffset}]
+}
+
+\doifdocumentargumentelse {noduplex} {yes} {
+ \setuppagenumbering
+ [alternative=doublesided]
+ \setdocumentargument{sided}{doublesided}
+} {
+ \setdocumentargument{sided}{singlesided}
+}
+
+\setdefaultdocumentargument {textwidth} {0cm}
+\setdefaultdocumentargument {backspace} {0cm}
+\setdefaultdocumentargument {topspace} {0cm}
+
+\setuplayout
+ [backspace=\getdocumentargument{backspace},
+ topspace=\getdocumentargument{topspace},
+ width=middle,
+ height=middle,
+ location=middle,
+ header=0pt,
+ footer=0pt]
+
+\doifdocumentargument {marking} {yes} {
+ \setuplayout
+ [marking=on]
+}
+
+\startluacode
+ local printformat = document.arguments.printformat or ""
+ if printformat == "" then
+ printformat = "normal"
+ elseif string.find(printformat,".*up") then
+ printformat = "2UP,\\v!rotated"
+ elseif string.find(printformat,".*down") then
+ printformat = "2DOWN,\\v!rotated"
+ elseif string.find(printformat,".*side") then
+ printformat = "2SIDE,\\v!rotated"
+ end
+ document.setargument("printformat",printformat)
+\stopluacode
+
+\setuparranging
+ [\getdocumentargument{sided},
+ \getdocumentargument{printformat}]
+
+\starttext
+
+\startluacode
+ local format = string.format
+ local fprint = function(...) tex.sprint(tex.ctxcatcodes,format(...)) end
+
+ if #document.files > 0 then
+ if document.arguments.sort then
+ table.sort(document.files)
+ end
+ local emptypages = document.arguments.addempty or ""
+ local textwidth = document.arguments.textwidth or "0cm"
+ for _, filename in ipairs(document.files) do
+ if not string.find(filename,"^mtx%-context%-") then
+ context.insertpages (
+ { filename },
+ { emptypages },
+ { width = textwidth }
+ )
+ end
+ end
+ else
+ fprint("no files given")
+ end
+\stopluacode
+
+\stoptext
+
+
+