12

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

Kornel Kisielewicz
  • 55,802
  • 15
  • 111
  • 149
John
  • 121
  • 1
  • 3
  • 1
    You have somehow managed to ask a question with exactly the same title as another question which asks the same thing: http://stackoverflow.com/questions/1465665/passing-command-line-arguments-to-latex-document – Will Robertson Jan 10 '10 at 01:13
  • 1
    That may be true, but *this* question helped me, and that one didn't. I read that one first, too. – zebediah49 Feb 11 '13 at 18:40

1 Answers1

11

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.

Yan King Yin
  • 1,189
  • 1
  • 10
  • 25
Joseph Wright
  • 2,857
  • 22
  • 32