views:

195

answers:

2

Hello there,

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

+3  A: 

Yup, something like:

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

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

Joseph Wright
A: 

Thanks Joseph; it works just fine! John

John
You should accept Joseph's answer by clicking on the tick mark for his answer. Usually, "thanks" responses go as comments.
Alok