Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing command-line arguments to LaTeX document

I have a LaTeX file, 'myfile.tex' say, that sometime in the middle of the code an ASCII file with LaTeX macros has to be input, 'macrofile.tex, say, through an '\input{macrofile}' command. Actually, there are more than one 'macrofiles', so every time I have to edit 'myfile' and change the name of 'macrofile'. I can avoid the edit part by using a \typein command, yet, I'd still have to enter the name from the keyboard. Is there any way to do that from the command line? So, to summarize, 'myfile.tex' looks like:

\documentclass{article}
........................
.......................
.......................
\begin{document}
.......................
......................
.......................
.......................
........................
.......................
\input{macrofile1} OR {macrofile2} OR {macrofile3} ETC...
.......................
......................
......................
....................
.....................
\end{document}

Can I pass the name of 'macrofile' as an argument to 'myfile.tex'?

Thanks

John

like image 899
John Avatar asked Jan 09 '10 15:01

John


1 Answers

Yup, something like:

latex "\def\myvar{info-to-pass} \input{<filename>}"

should do you. You can then use \myvar in your document.

The \input{...} specifies the filename for the latex command.

like image 109
Joseph Wright Avatar answered Nov 09 '22 23:11

Joseph Wright