It's not graphs. It's a .tex file that I want to include. I used \input and it worked fine. But as I keep writing more and more, the file got bigger and bigger and I decided to use chapterbib to make the reference clearer. I used natbib and I found for chapterbib to work, I must use \include and not \input.

When I changed to \include, it wouldn't compile any more.

I can't write on file `"Literature review/M.aux"'.
\@include ...\immediate \openout \@partaux #1.aux 

\immediate \write \@partau...
l.67 \include{"Literature\space review/M"}

(Press Enter to retry, or Control-D to exit; default file extension is `.tex')
Please type another output file name
! Emergency stop.
\@include ...\immediate \openout \@partaux #1.aux 
\immediate \write \@partau...
l.67 \include{"Literature\space review/M"}

I found this but it doesn't work. How to make \include work with a quoted string path containing spaces?

I tried some combinations.

This works: \include{review\M} (supposing I have a file call "M.tex" in folder of "review" and the folder "review" is in the same folder of my base tex file)

This works: \include{"M\space 1"} (supposing I have a file call "M 1.tex" in the same folder of my base tex file)

But this doesn't work: \include{"Literature\space review/M"} (supposing I have a file call "M.tex" in folder of "Literature review" and the folder "Literature review" is in the same folder of my base tex file)

Someone asked if this works: \include{"Literature review/M"}. No. It gives no error, but the output will simply be review/M.

I found someone said to change TEXINPUTS in bash. I did not understand it at all. I'm using windows. I don't know how to change the path.

I found this did not work either. How to include graphics with spaces in their path?

How could I make it work? Thanks!


I replaced all the spaces with underlines and still it didn't work. Is it because my file is too deep? It is \include{{"Folder_A/B/C/D/M"}}. LaTeX still reported that it could not write the 'Folder_A/B/C/D/M.aux' file. So perhaps it was not the spaces that caused the issue in the first place.
Any idea?

  • 2
    Why do you need spaces in your path names? My suggestion would be to use underscore _ for spaces, which should solve your problem.
    – Werner
    Commented Nov 5, 2015 at 1:40
  • That's just a simplified example. I have so many folders, and some of them contain a lot of words separated by spaces. I don't want to change them one by one. I would rather just replace all the \input with \include.
    – fyang
    Commented Nov 5, 2015 at 1:45
  • Change them one-by-one? Windows doesn't allow "multiple" (or "mass") renaming?
    – jon
    Commented Nov 5, 2015 at 2:05
  • 6
    I'm rather certain that you already spent more time on getting spaces to work that it would have cost you to remove the spaces from the folder and files names ... Even if you find some way to handle the spaces: it can always break if you move to some other os. It is not worth the time. Commented Nov 5, 2015 at 9:13
  • 1
    \include{Folder_A/B/C/D/M}, I guess. Why do you need anything that deep in terms of directory structure? Seems very strange....
    – cfr
    Commented Nov 6, 2015 at 0:23

2 Answers 2


For the name ‘amo amas amat’, this works under TeX Live on GNU/Linux:

  "amo\space amas\space amat"
\include{"amo\space amas\space amat"}

and this works under MiKTeX on Windows:

  {"amo amas amat"}
\include{{"amo amas amat"}}

Reference: 24.2 \include & \includeonly


There is no way to escape spaces and quotes. If you must, change \include's definition.

      \@latex@error{\string\include\space cannot be nested}\@eha
            \expandafter\string\csname #1\endcsname
      \expandafter\@include\expandafter{\@curr@file} % trailing space

Generally, never use quotes and redundant braces unless you know what you are doing. In \includeonly, a \space is welcomed for space escaping.

\includeonly{a\space b}

For \input, simply cover the path with braces. \input{a b}, \input "a b" are both ok.

You must log in to answer this question.

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