Consider the file define.tex.

submit macro is defined
submit macro is not defined
\added{if these words are highlighted, this corresponds to draft
  option. not highlighted corresponds to final option}

Inspired by Will's answer to "Passing command-line arguments to LaTeX document", and Martin's answer to "Passing parameters to a document"

I tried


and also


In both of these cases, only the first option is seen, as one can check. One would expect the result for both to be "submit macro is defined" with highlighting below, but in fact in one case we get

"submit macro is defined" + highlighting (\def first)

and the other

"submit macro is not defined" + no highlighting (\PassOptionsToPackage first)

This seems like unexpected behavior to me. If I use two similar \defs, there is no problem. I.e. something like


works as expected with the following file.

foo macro is defined
foo macro is not defined
bar macro is defined
bar macro is not defined

Ie. the file has

foo macro is defined bar macro is defined

EDIT Aug 21st 2011: I was mistaken about foo and bar. Since \bar was already defined, it was a bad choice. Thanks to T.H. for the clarification and for answering the main question. It seems that if I have a set of options passed to pdflatex like so

pdflatex 'somestuff' 'somemorestuff\input{define}' 'yetmorestuff' [...]

then the 'yetmorestuff' option is not seen by pdflatex. If this is correct, then I don't understand this behavior. T.H. said "The first time you use \input{define}, TeX parses to the end of the file, sees \end{document} and then stops."

However, this is not how option passing normally works. Can someone give me some background on the mechanisms involved here? Thanks.

  • There is no option passing going on here. You're providing a line of input to TeX. In particular, this is identical to your having written somestuff somemorestuff\input{define} yetmorestuff into a file and then run pdflatex on that file.
    – TH.
    Aug 21, 2011 at 8:59
  • @Th.: Thanks for your reply. If TeX simply concatenates lines of input, then wouldn't the commands as above, i.e. pdflatex 'somestuff\input{define}' define.tex have define.tex included twice? This does not seem to be the case. Aug 21, 2011 at 13:02
  • As I already stated, the \end{document} causes TeX to stop reading input. \end{document} (more or less) expands to \enddocument which expands to a bunch of stuff ending with \@@end. \@@end is the TeX primitive \end which causes TeX to stop.
    – TH.
    Aug 25, 2011 at 23:43
  • @TH.:Ok, so in the above case, the second define.tex is redundant, right? Aug 26, 2011 at 16:31
  • Yes. The first line of input TeX sees is treated as a file name, unless it begins with a \. That's why pdflatex foo reads foo.tex. You can see this by running pdflatex by itself. It waits for input with a prompt of **. If you enter a file name, it'll typeset it. If you enter something like \relax, then you'll get a prompt * which is treated as the next line of input.
    – TH.
    Aug 28, 2011 at 3:55

1 Answer 1


The first time you use \input{define}, TeX parses to the end of the file, sees \end{document} and then stops.

  • But my second (corrected) example (foo, bar) works. Isn't this a counterexample? And if this the problem, what is the remedy? Aug 15, 2011 at 20:48
  • No. \bar is already defined to be \mathaccent "7016\relax. It's doing exactly the same thing. Notice that it only claims that foo macro is defined once, not twice as you would expect if it were actually typesetting define.tex twice.
    – TH.
    Aug 15, 2011 at 20:51
  • You're right. I forgot \bar is some math thing. Ok, so what are my options? Can I stick just one \input{define} at the end? Based on a brief test, it looks like that works. Ie. \def\foo{}\def\baz{}\input{define}. Aug 15, 2011 at 20:55
  • I'm not sure what your goal is here. Do you want this typeset twice? If you're just trying to define a few things before \inputting the document, then yes, define it and end with \input. If you're trying to typeset things multiple times with different options, you need to do something else.
    – TH.
    Aug 15, 2011 at 20:59
  • Just trying to define a few things before input so I can use it in the text. See my example. Thanks. Aug 15, 2011 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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