Consider the file define.tex
.
\documentclass{article}
\RequirePackage{changes}
\makeatletter
\@namedef{Changes@AuthorColor}{red}
\colorlet{Changes@Color}{red}
\makeatother
\begin{document}
\ifdefined\submit
submit macro is defined
\else
submit macro is not defined
\fi
\added{if these words are highlighted, this corresponds to draft
option. not highlighted corresponds to final option}
\end{document}
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
pdflatex
'\PassOptionsToPackage{final}{changes}\input{define}\def\submit{}\input{define}'
define.tex
and also
pdflatex
'\def\submit{}\input{define}\PassOptionsToPackage{final}{changes}\input{define}'
define.tex
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
'\def\foo{}\input{define}\def\bar{}\input{define}'
works as expected with the following file.
\documentclass{article}
\begin{document}
\ifdefined\foo
foo macro is defined
\else
foo macro is not defined
\fi
\ifdefined\bar
bar macro is defined
\else
bar macro is not defined
\fi
\end{document}
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.
somestuff somemorestuff\input{define} yetmorestuff
into a file and then run pdflatex on that file.pdflatex 'somestuff\input{define}' define.tex
havedefine.tex
included twice? This does not seem to be the case.\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.define.tex
is redundant, right?pdflatex foo
readsfoo.tex
. You can see this by runningpdflatex
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.