A script to automate LaTeX\LaTeX for generating multiple pdf outputs for changing variables.

This script was written to generate multiple latex documents by changing defined variable in the latex file. Generating multiple sets for examination are often required and became a necessity in the pandemic with online examinations. As they say 'Necessity is the mother of invention' I wrote this script for a course that I was involved in.

Sample LaTeX\LaTeX file.

Variables that need to be cycled through values can be defined using \newcommand{variablename}{value} in the beginning of the .tex file.


\date{September 21}

This : $\xvar$  is a variable.$\varphi$. This:new should not be replaced.
    \item $ x = \xvar$ 
    \item $ y = \yvar$
    \item $ z = \zvar$
    \item $ w = \wvar$

How to use the script

In the python file ( (Link for the github rep) you can find the function replace() defined. It takes the tex file as the first input and a python dictionary as the second input.



In the example above, there are 4 variables defined. The value of dictionary key 0 will replace the value of \xvar variable, value for key 1 will replace the value for \yvar and so on.

The script uses pdflatex so make sure you have pdflatex installed in your system before using the script.

Note: the dictionary can be automated and the first value in the dictionary matches the first values in the Skeleton Latex file.