1

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

Gopi
  • 1,020
  • Does this help: http://tex.stackexchange.com/questions/24357/how-do-i-set-document-options-at-compile-time – cmhughes Oct 09 '11 at 15:55
  • 1
    It indeed seems close to http://tex.stackexchange.com/questions/1492/passing-parameters-to-a-document. I need to take a closer look, see if I can get my answer. Thanks – Gopi Oct 09 '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 09 '11 at 16:18

1 Answers1

4

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 09 '11 at 16:33
  • 2
    try -jobname=a –  Oct 09 '11 at 16:50