[pdftex] creating multiple versions of same document
Magnus Lie Hetland
mlh at idi.ntnu.no
Wed Mar 28 18:51:38 CEST 2001
> The easiest way I can think of is to prepare three files: double.tex,
> single.tex and screen.tex, with proper preambles and as a body:
>
> \begin{document}
> \input mythesis
> \end{document}
>
> but I'm curious after other peoples tricks...
You could also use some macro program, either m4 or sed, or some
scripting language (Python, Perl) and leave fields in the document
for some definitions... Like (with Python):
---- in test.tex ----
\documentclass%(options)s{article}
%(otherstuff)s
\begin{document}
...
\end{document}
---------------------
Then, to produce a two-sided version set with Palatino, you
could do the following:
---- in test.py ----
params = {}
params["options"] = "[twoside]"
params["otherstuff"] = r"\usepackage{mathpple}"
output = open("outfile.tex", "w")
input = open("test.tex", "r")
output.write(input.read() % params)
input.close()
output.close()
--------------------
This example used some pretty stupid names etc., but shows the
principle, anyway.
The nice thing about using the Python macro facility with
TeX is that if you only put the macro fields on separate lines
(or at the end of a line) they will be treated as comments
by LaTeX if you don't use then, since they begin with a
percent sign... :)
--
Magnus Lie Hetland http://www.hetland.org
"Reality is that which, when you stop believing in
it, doesn't go away." -- Philip K. Dick
More information about the pdftex
mailing list