web2c: \input filenames

 
 3.5.4 '\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.)
 
    As of Web2c version 7.5.3, double-quote characters can be used to
 include spaces or other special cases.  In typical use, the '"'
 characters surround the entire filename:
      \input "filename with spaces"
 
    Technically, the quote characters can be used inside the name, and
 can enclose any characters, as in:
      \input filename" "with" "spaces
 
    One more point.  In LaTeX, the quotes are needed inside the braces,
 thus
      \input{a b}    % fails
      \input{"a b"}  % ok
 
    This quoting mechanism comes into play _after_ TeX has tokenized and
 expanded the input.  So, multiple spaces and tabs may be seen as a
 single space, active characters such as '~' are expanded first, and so
 on.  (See below.)
 
    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.  In addition, 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 another way to get a program to read a filename containing
 whitespace is to define an environment variable and dereference it.)
 
    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.