How can I dynamically import a tex file?
I essentially have hundreds of .tex files in one folder, all of these files have multiple versions. I can't move them out of this folder.
Ex:
ver1file1.tex
ver2file1.tex
...
ver8file1.tex
...
ver8file100.tex
I want to be able to set a environment variable or pass a command line argument so that latex will be able to dynamically load all the files from a particular version.
Example:
pdflatex ver1
or
EXPORT LATEX_VER=ver1
to have only the following being imported in the main latex file.
ver1file1
ver1file2
...
ver1file100
Below is an example of what i've tried so far but I can't get the I basically want to have 2 .tex files, file1.tex
and file2.tex
. I want to be able to accept a command line argument that defines the name of the file to import.
main.tex
\import{c:\path}{aux}
\import{c:\path}{\dynavar} % should load variable from commandline + added string ex: ver1file1
aux.tex
%accept a command line argument
\ifdefined\myflag
\newcommand\dynavar[1]{\emph{#1}}
\else
\newcommand\dynavar[1]{defaultval}
\fi
\expandafter\def\expandafter\dynavar\expandafter{\dynavar { }file1}
Best Answer
Here's a small mockup of what I would suggest:
You would call the above file using
to run
ver1
of the files. Orif you wish it to run
defaultval
of the files. Using\def\dynavar{ver1}
as the "command line" option, you'll get the output