[Tex/LaTex] LaTex \include space in path

includepaths

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!

Update:

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?

Best Answer

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

\documentclass{book}
\includeonly{
  "amo\space amas\space amat"
  }
\begin{document}
\include{"amo\space amas\space amat"}
\end{document}

and this works under MiKTeX on Windows:

\documentclass{book}
\includeonly{
  {"amo amas amat"}
  }
\begin{document}
\include{{"amo amas amat"}}
\end{document}

Reference: 24.2 \include & \includeonly

Related Question