TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to latex. I would like to pass command line arguments (probably more) to \newcommand macro and expecting output like below.

if input is 1
      /include {1.tex}  

else if input is 2
      /include {2.tex}
else if input is 3
      /include {3.tex}     
else if input is 1 and 2          
      /include {1.tex}        
      /include {2.tex}
else if input is 1 and 2  and 3       
      /include {1.tex} 
      /include {2.tex}    
      /include {3.tex} 

and so on. I have heard some xkeyval, xargs packages do like this. But i am not sure about its implementations.

How can i give too many arguments to latex? How can i parse/differentiate the arguments and then pass accordingly?

share|improve this question
It looks like you want to have something like a \multiinput{1,2,3}, in other words input is the name of the files to be added. Am I right? – percusse Mar 26 '13 at 14:41
Hi Thanks for the reply.Input is not the name of file. It is actually any word (for example bird, vehicle), depends on the word i should add files probably, in following loop (ex:if word =bird then /include{parrot.tex} /include{dove.tex} else if word = vehicle then /include{car.tex} /include{bike.tex} ) – BusyBee Mar 27 '13 at 12:16

Here's an example of a umaraman.tex file:




Of course the files can be named as you wish. If you call from the command line

pdflatex "\def\umafiles{uma1,uma3}\input{umaraman.tex}"

only uma1 and uma3 will be input. If you instead call normally

pdflatex umaraman.tex

all files will be input.

share|improve this answer

Your Answer


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.