cleanlatex
This is a small collection of perl scripts to clean a latex source in order to transform a manuscript into a camera-ready version for submission. It consists of
- cleanltxbase.pl, a perl script which removes all comments
from the latex source (but retains all % marks and does not touch \%, both of which is
important for proper functionality) and replaces all \def definitions by
\newcommand counterparts
- cleanltxdef.pl, a perl script which searches the
document preamble (the part before \begin{document}) for unused and duplicate definitions
and removes them
- cleanltxbranches.pl, a perl script which flattens
all conditional branches of the document of the type
\newif\ifsomething\somethingtrue ... \ifsomething (branch) \else (alternative branch) \fi
- cleanlatex.sh, a shell script which uses the three perl
scripts to generate the cleaned version clean.<sourcefile>
(for Windows, there is the batch file cleanlatex.bat)
Usage
Just type "cleanlatex <sourcefile>"
where <sourcefile> is the full filename including extension. The output
will be written to clean.<sourcefile>
Attention:
- include all packages you are using (which you are not planning to provide)
directly into the preamble of the latex source before processing
- cleanltxbase.pl and cleanltxdef.pl consider only definitions that start directly at the
beginning of one line (knowing this, you can protect definitions from being processed)
- cleanltxdef.pl additionally requires that definitions contain no line breaks. If the line would
become too long, it is sufficient that the definition is in one "logical" line. That is, you may break
lines after the head (\newcommand{\somecommand}) of the definition, but make the lines end with %
- the scripts do not remove duplicate definitions from packages used,
if you have previously overwritten definitions by means of \def, this is a possible
source of errors which you have to remove manually
- I tested the scripts, but still they are probably not free of bugs, so please
check your final output carefully
Installing cleanlatex
Download all scripts or just the complete package:
cleanlatex.zip.
Unix/Linux: Make sure that a perl interpreter is installed, if necessary
check that the first line of the perl scripts points to the interpreter. Copy
the scripts somewhere your system can locate them (e.g. ~/bin), make
sure they are executable, and rename cleanlatex.sh to cleanlatex if you like.
Windows: Make sure that a perl interpreter is installed, and modify the
first line of the perl scripts such that it points to the interpreter. Use the
batch file cleanlatex.bat instead of cleanlatex.sh, and copy the scripts
somewhere your system can locate them.
Copyright: none
March 8, 2006, Jan Poland
|