# How to give arguments to a tex file during compilation?

I have a file called main.tex, which looks like this:

\begin{document}
\input{a.tex}
\end{document}


I want to know if it is possible to have it take this file a.tex in argument, such that I could compile it in a manner that depending on the argument it gives a different output automatically.

Something like pdflatex main.tex < a.tex > a.pdf

-
Does this help: tex.stackexchange.com/questions/24357/… –  cmhughes Oct 9 '11 at 15:55
It indeed seems close to tex.stackexchange.com/questions/1492/…. I need to take a closer look, see if I can get my answer. Thanks –  Gopi Oct 9 '11 at 16:07
Ok, it is not exactly working the same way since they seem to be working the other way around: changing the headings instead of the content. I suppose theoretically we could do it symetrically but it is not obvious to me :s. –  Gopi Oct 9 '11 at 16:18

run

pdflatex '\def\myfile{a.tex} \input main.tex'


and a main.tex with

\begin{document}
\input{\myfile}
\end{document}

-
Awesome, that was what I needed. Is there then a way such that latex gives to the output the name "a.pdf" (otherwise I will add the bash command "mv main.pdf a.pdf", but it seems less understandable than if it had the name in the first place :s) –  Gopi Oct 9 '11 at 16:33
try -jobname=a –  Herbert Oct 9 '11 at 16:50