Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
    
Does this help: tex.stackexchange.com/questions/24357/… –  cmhughes Oct 9 '11 at 15:55
1  
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
add comment

1 Answer

up vote 4 down vote accepted

run

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

and a main.tex with

\begin{document}
\input{\myfile}
\end{document}
share|improve this answer
    
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
2  
try -jobname=a –  Herbert Oct 9 '11 at 16:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.