TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to import graphics into my main input file using the macro \includegraphics. It does not work if the filename contains spaces.

Include image with spaces in path directory to be processed with dvips also discusses this subject, but there is no solution there.

My compilation routine is latex->dvips->ps2pdf (because of PSTricks).

share|improve this question
Is it the path that contains spaces (e.g., with the \graphicspath command), or the filename? Those aren't the same. – frabjous Jan 7 '11 at 3:43
@frabjous, for generalization, both \graphicspath and \includegraphics contain paths with spaces. – xport Jan 7 '11 at 3:52
@TH., there is no solution there :-) – xport Jan 7 '11 at 3:53
Jimi Damon wonders which of the below solutions work if the filename contains a comma in the name. Comments? – Benjamin McKay Jul 19 at 20:27
up vote 28 down vote accepted


\includegraphics{"file name.eps"}

The macro \Ginclude@eps is defined in the file dvips.def. It uses \special{PSfile="#1"\space ... which causes problems if additional "" are used. I patched this, such that it behaves like it was written PSfile=#1 and it worked for me in a test with an eps file with a space in the name and dvips.

share|improve this answer
Thanks for answering. However, it does work only when we don't use \graphicspath. – xport Jan 16 '11 at 1:19
@xport: I'm glad to hear that it works. Since \graphicspath was not part of the question, it did not test with it. I'll do later. – Stefan Kottwitz Jan 16 '11 at 2:20

Use package grffile:

[ ... ]
\includegraphics[...]{A file with spaces}
share|improve this answer
all permutations have been tried, but none works. :-) – xport Jan 7 '11 at 7:11
ok thanks for answering. – xport Jan 7 '11 at 7:16
This worked for me, thanks! – Adam Nellis Sep 28 '11 at 10:28
This also work for me... thanks.. – Mohammad Fajar Feb 24 '14 at 9:21
Worked for me, too. Thanks! – Manuel Rauber May 22 '14 at 11:58

A simpler solution would be...

\includegraphics{{"../Current folder/1.This file"}.png}

(For Windows users,) note that the slashes all need to be forward slashes.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.