How can I compile a file with two consecutive spaces in the filename? The following compiles when named file name.tex, but not when named file{two spaces here}name.tex (sorry, the editor here converted the two consecutive spaces in the name to a single space, so I had to get creative):

    File name with two spaces fails to compile. 

The error I am getting is:

This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/W32TeX) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode ! I can't find file `"./file name.tex"'. <*> "./file name.tex"


  • BTW, I can't change the filename after the fact for unrelated reasons: I am using xr to hyperlink between two documents, and in order for the hyperlinks to work, I can't change the filenames after compilation. Unfortunately, this is for an article I'm submitting to a journal. I'm trying to make the reviewers' life easier by having functioning hyperlinks, but the journal renames the files and the new file names include two consecutive spaces.
    – Chai
    Commented Feb 19, 2020 at 15:13
  • 4
    I would say you are out of luck here. It doesn't compile for me on a current texlive and a current miktex neither. pdflatex looks for a file with one space.You could make a bug report at the texlive list. But even if it gets corrected it will probably take some time until new binaries are available. Tell the journal to remove the second space. Commented Feb 19, 2020 at 16:58
  • 2
    Including several consecutive spaces (or newline chars, while we're at it!) in file names is quite a wicked idea (I know it is not the OP's choice).
    – frougon
    Commented Feb 19, 2020 at 17:21
  • 1
    Actually David found a way to compile it: you can try to call the compilation with pdflatex "file\space\space name". Commented Feb 19, 2020 at 17:44

1 Answer 1


you can input a file with multiple spaces in its name by



\input{"a\space\space b.tex"}


which works as you can see on the terminal

LaTeX2e <2020-02-02> patch level 2
L3 programming layer <2020-02-14>
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(./cc640.aux) (./a  b.tex) [1{/usr/local/texlive/2019/texmf-var/fonts/map/pdfte
x/updmap/pdftex.map}] (./cc640.aux) )</usr/local/texlive/2019/texmf-dist/fonts/

On the commandline you can use

$ tex "a\space\space b"
This is TeX, Version 3.14159265 (TeX Live 2019) (preloaded format=tex)
(./a  b.tex)

  • Wicked. Really wicked.
    – vonbrand
    Commented Feb 19, 2020 at 23:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .