# Setting TEXINPUTS for pdflatex in Ubuntu

I have a set of files that are commonly used as inputs in my tex files, so I put them in a directory and set the path in the TEXINPUTS environment variable (in Ubuntu). This works fine when compiling files with the latex command, but if I compile them with pdftex, it gives the following error message:

``````! I can't find file `{header.tex}'.
``````

As far as I can tell, pdftex is completely ignoring the TEXINPUTS environment variable. Does it use a different environment variable? How can I get it to recognise a path?

• Are you using `pdftex` or `pdflatex`. The latter will read `\input{header.tex}` as a braced argument for file `header.tex`, but `pdftex` is Knuth's plain format with the pdfTeX engine: there, `\input` has primitive syntax only, and the file name searched is `{input.tex}`. – Joseph Wright Nov 18 '12 at 12:38
• Aha! pdflatex works, but pdftex doesn't. Thanks for explaining. – thornate Nov 18 '12 at 12:52
• I'll write that up in a slightly modified form as an answer, then :-) – Joseph Wright Nov 18 '12 at 13:06
• Start your documents with `\NeedsTeXFormat{LaTeX2e}` to get a meaningful error message if you use the wrong program. – Martin Schröder Nov 19 '12 at 7:41

The `latex` command runs LaTeX in DVI-output mode. LaTeX's definition of `\input` allows for a syntax

``````\input{<file-name>}
``````

where the `<file-name>` is read as a braced argument. The `pdflatex` command will do exactly the same but with direct PDF output.

On the other hand, `pdftex` runs plain TeX with direct PDF output. The plain TeX definition for `\input` uses a 'primitive' syntax, in which the name is read as any tokens at all up to the first space. Thus with `pdftex`

``````\input{<file-name>}
``````

ends up looking for a file called `{<file-name>}`, including the braces.

• It may be worth noting that `\input{filename}` works also in LuaTeX (as opposed to LuaLaTeX). – egreg Nov 18 '12 at 13:46
• @egreg One of the 'features' of LuaTeX which gives me headaches :-) – Joseph Wright Nov 18 '12 at 14:00