12

In Windows, \input can work with a quoted string path containing spaces, but \include cannot. How to fix it?

\documentclass{book}
\begin{document}

%\input works!
\input{"Contents/Installing and Configuring IIS 7/Configuring Security"}

%but \include does not work!
%\include{"Contents/Installing and Configuring IIS 7/Configuring Security"}
\end{document}
Display Name
  • 46,933
  • I deleted my answer because I'm not sure if that's really a solution. It was just a guess. So I will comment, instead. Do you get a "No file" error message? Could you try to enter "\includeonly{"Contents/Installing and Configuring IIS 7/Configuring Security"}" in the preamble first. Maybe "\include" would work after this. – Jimi Oke Dec 13 '10 at 04:32
  • @jimi, it did not and does not make sense. If it works like so, the other \include will be ignored, right? – Display Name Dec 13 '10 at 06:59
  • @xport: sorry, that really did not make any sense. You may find the answer to your question here: http://stackoverflow.com/questions/2444385/include-a-tex-file-with-spaces-in-the-filename. Someone else also had this problem a while back. It probably has something to do with the version of your distribution. – Jimi Oke Dec 13 '10 at 07:07
  • My knowledge of the include command is not that in-depth but as far as I understand, \includeonly reprocesses the specified file already called in the document through \include. I guess its only useful when you have multiple files and only want to work with a few. \include is never ignored, though, since that's what really makes the document. Check out the solutions from the link. If nothing works, fastest thing to do would be just to rename your file without spaces and you should be fine. – Jimi Oke Dec 13 '10 at 07:16
  • Does escaping the spaces work: \include{file\ name} – Seamus Dec 16 '10 at 09:50
  • @Seamus, have you tried it? – Display Name Dec 16 '10 at 11:16
  • @xport I can't: I don't have access to a windows computer – Seamus Dec 16 '10 at 13:42
  • Your feelings about Windows seems sort of irrelevant here. If you mean that you need a solution that works for MiKTeX on Windows, that's what you should say. – TH. Dec 18 '10 at 13:30

2 Answers2

14

You could use \space within the file name, which works for me with \include on Windows:

\include{"Configuring\space Security"}

It works with paths and with file names. An .aux files with blanks in the file name would be produced, \includeonly works as well if \space is used too.

Stefan Kottwitz
  • 231,401
3

You can try to protect the filename with an additional brace. On miktex/winxp this works:

\documentclass{article}
\includeonly{{"test space"}}
\begin{document}
\include{{"test space"}}
\end{document}

But don't expect it to work on other systems too! If you need something reliable remove better the spaces.

Ulrike Fischer
  • 327,261
  • can we substitute \input for \include with additional commands? – Display Name Dec 13 '10 at 11:02
  • Well internally \include is \input with additional commands. So naturally you can replace it. But what do you want to achieve? – Ulrike Fischer Dec 13 '10 at 11:11
  • @Ulrike, thanks first. I need a new \include-like inclusion command that can accept string path with spaces, of course. – Display Name Dec 14 '10 at 00:47
  • I guessed that. But which features of \include do you actually need? And did you actually tried my solution? If yes why doesn't it help you. – Ulrike Fischer Dec 14 '10 at 11:18
  • @Ulrike, your solution did not work. I got nothing. – Display Name Dec 16 '10 at 08:02
  • @xport: "I got nothing" doesn't give any information that'd be needed to figure out why it doesn't work for you. Did you get an error? Was there a message in the log? Something else? – TH. Dec 18 '10 at 13:28
  • @TH. : Sorry, I didn't read your comment. As I already have the solution from Stefan, I am no longer interested to figure out the details pertaining to "I got nothing". :-) – Display Name Jun 04 '11 at 09:01