In a tex.SX user profile, I read the best practice recommendation
Execute
pdflatex \input{filename}
instead ofpdflatex filename
.
I have always used the latter one, directly, in scripts, and in Makefiles.
What would be a reason to always use pdflatex \input{filename}
instead?
Best Answer
Advantages
It is a good trick, if someone wants to put TeX code before. Examples:
or inside
\write18
(shell escape feature):e-TeX's
\detokenize
prevents the expansion of the macros inside\write
, see question.Also LaTeX catches the error message a little better, because it checks for the file first and throws a proper error message.
The TeX behaviour of '\input' without braces or on the command line would be:
Then you can escape from there with
Control-D
(Unix) orControl-Z
(Windows). or the filex.tex
of LaTeX's tools bundle can be used for this purpose.LaTeX throws instead:
Then LaTeX already looks for
x
orX
as answer to abort the job.Answer to a comment: However, in both variants an error message is thrown, if the file does not exist. An interactive prompt in a command chain (
pdflatex test && do something
) can be avoided by the pdfTeX optionsinteraction=batchmode
or--interaction=nonstopmode
.Disadvantages
filename
.Summary
IMHO the two described "advantages" are indeed too weak for always using
pdflatex \input{test}
overpdflatex test
. At least I have tried to find possible reasons. And the trick with putting TeX stuff before\input
is worth to be remembered.