[XeTeX] spaces in filenames

Jonathan Kew jonathan_kew at sil.org
Thu Aug 10 12:04:58 CEST 2006

On 29 Jul 2006, at 9:28 pm, William Adams wrote:

> Was there ever a resolution on this?

There wasn't, but there is now. :)

I have just re-written the filename quoting code, and I think it  
works better now (and is more compatible with pdftex etc). If you  
check out and build the latest pre-0.995 code (rev 324 in  
Subversion), you should be able to handle names with spaces, without  
the .aux file problems (etc) that you've seen.

For your particular usage, there's one "gotcha" to watch out for: if  
the filename includes spaces, \jobname will return a quoted string.  
But fontspec's \setFOOfont{} macros want the name without quotes. So  
you'll need to strip quote marks from the \jobname string before  
using it in this context. Something like this should work, I think:

   \def\unquote at Jobname#1"#2"#3\end{\def\Jobname{#1}%
   \expandafter\unquote at Jobname\jobname""\end

   \setromanfont{\Jobname} % \Jobname is \jobname with quotes (if  
any) stripped

Strictly speaking, this is not always adequate: if the filename  
*includes* a double-quote character, then \jobname will return a  
single-quoted string instead; and there are even more complex/messy  
possibilities, if the name includes both types of quote marks. But  
for practical purposes, this will probably serve.

Ever considered how to handle a file named <Joyce's "Ulysses".tex>?!  
XeTeX can now do it:

   $ xetex Joyce\'s\ \"Ulysses\".tex
   This is XeTeX, Version 3.141592-2.2-0.995 (Web2C 7.5.5)
   entering extended mode
   (./Joyce's "Ulysses".tex [1] )
   Output written on Joyce's "Ulysses".pdf (1 page).
   Transcript written on Joyce's "Ulysses".log.

pdfTeX can't handle this case:

   $ pdftex Joyce\'s\ \"Ulysses\".tex
   This is pdfeTeX, Version 3.141592-1.30.4-2.2 (Web2C 7.5.5)
   entering extended mode
   ! I can't find file `"Joyce's Ulysses.tex"'.
   <*> "Joyce's Ulysses.tex"

   Please type another input file name: ^D
   ! Emergency stop.

(Running in a directory where the file *does* exist, of course.)


More information about the XeTeX mailing list