What characters can be used in filenames for the main document and input files, both .tex
and images etc.? I'm not asking about which are recommended to be used, but about a list of all possible characters a user could ever use in a filename. This is important to know in order to support those in filename related packages (e.g. currfile
, svn-multi
, …).
I can see two use cases here:
- On the command line, e.g. using
pdflatex <filename>
.
Which might require single-quotes and/or\
to escape characters special to the command line shell, but then maybe again for TeX. - Inside (La)TeX itself, e.g.
\input{<filename>}
.
For example: The use of %
in (main document) filenames seems not possible with LaTeX using TeXLive 2011 under Linux. A pdflatex 'test%it.tex'
results in a prompt and entering \relax
there gives: ! I can't find file `test'.
. So the %
is also used as comment character in this case.
There seems to be more going on with filenames on the command line because I got the following warning:
# pdflatex 'test$it*gdg!£$^&%_*(){.tex'
warning: test$it*gdg!£$^&%_*(){.tex: Unrecognized variable construct `$^'.
Best Answer
The filename syntax is one of the few explicitly system dependent parts of TeX-the-program.
In texlive (ie web2c tex) most characters are allowed (especially after the syntax was changed to allow
"
quoting names including spaces). Of course the characters are interpreted by TeX's macro expansion before being considered as possible filename characters, so%
and friends need special handling.This inputs
test%it.tex
on my texlive 2010 (using a cygwin bash shell in windows, but I imagine other command lines would be similar)The warning about
$
that you mention comes from kpathsea, as described in its manualyou can test kpathsea's handling with tests sch as
which shows that you can refer to environment variables from with tex, kps.tex is
a b c.tex
isand ZENV.tex is