Go to the first, previous, next, last section, table of contents.


\input filenames

TeX, Metafont, and MetaPost source programs can all read other source files with the \input (TeX) and input (MF and MP) primitives:

\input name % in TeX

The file name can always be terminated with whitespace; for Metafont and MetaPost, the statement terminator `;' also works. (LaTeX and other macro packages provide other interfaces to \input that allow different notation; here we are concerned only with the primitive operation.) This means that \input filenames cannot directly contain whitespace, even though Unix has no trouble. Sorry.

On the other hand, various C library routines and Unix itself use the null byte (character code zero, ASCII NUL) to terminate strings. So filenames in Web2c cannot contain nulls, even though TeX itself does not treat NUL specially.

Furthermore, some older Unix variants do not allow eight-bit characters (codes 128--255) in filenames.

For maximal portability of your document across systems, use only the characters `a'--`z', `0'--`9', and `.', and restrict your filenames to at most eight characters (not including the extension), and at most a three-character extension. Do not use anything but simple filenames, since directory separators vary among systems; instead, add the necessary directories to the appropriate search path.

Finally, the present Web2c implementation does `~' and `$' expansion on name, unlike Knuth's original implementation and older versions of Web2c. Thus:

\input ~jsmith/$foo.bar

will dereference the environment variable or Kpathsea config file value `foo' and read that file extended with `.bar' in user `jsmith''s home directory. (You can also use braces, as in `${foo}bar' if you want to follow the variable name with a letter, numeral, or `_'.)

(So you could define an environment variable value including whitespace and get the program to read such a filename that way, if you need to.)

In all the common TeX formats (plain TeX, LaTeX, AMSTeX), the characters `~' and `~' have special category codes, so to actually use these in a document you have to change their catcodes or use \string. (The result is unportable anyway, see the suggestions above.) The place where they are most likely to be useful is when typing interactively.


Go to the first, previous, next, last section, table of contents.