Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I have the following image that I wish to include in my document:

wget http://www.biomedcentral.com/content/figures/1471-2164-10-37-1-l.jpg -O exampleImg.jpg

I need to compile via dvi. I covert the jpg to eps format with GraphicsMagick:

gm convert exampleImg.jpg exampleImg.eps

I used the following latex code and it works compiling via dvi and ps.

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{grffile}

%\usepackage[pdftex]{graphicx}

%opening
\title{}
\author{}

\begin{document}

\includegraphics[]{./test/exampleImg}

\end{document}

When I use a directory with a space, test test, and it doesn't work anymore, even though I use \usepackage{grffile} :

\documentclass[a4paper,10pt]{article}
\usepackage[utf8x]{inputenc}
\usepackage{wrapfig}
\usepackage{graphicx}
\usepackage{grffile}

%\usepackage[pdftex]{graphicx}

%opening
\title{}
\author{}

\begin{document}

\includegraphics[]{./test test/exampleImg}

\end{document}

It gives the following error:

! LaTeX Error: Cannot determine size of graphic in ./test test/exampleImg (
no BoundingBox).
share|improve this question
    
Is there any reason you really want to stick with dvi and not go to pdflatex? –  Juan A. Navarro Oct 20 '10 at 9:26
    
Some things do not compile in pdflatex. PStricks seems to be one such thing. –  denilw Oct 22 '10 at 21:22
    
I open this bounty because I have the same problem as @denilw had. NOTE: This question has NOT been SOLVED even though @denilw gave a green check mark on @Will's answer. –  xport Jan 7 '11 at 7:20
    
FYI, when I used grffile for my dissertation to include many small PDF figures it took an order of magnitude longer to compile. –  edallme Mar 10 '13 at 7:56
add comment

2 Answers

up vote 6 down vote accepted
+50

With Will's code (added to the preamble after loading graphicx) and with this syntax to include the graphic: \includegraphics[width=5cm]{"Neuer Ordner/tiger"} I could process the document with latex + dvips on a miktex 2.9./win XP system . tiger.eps was used without problem. It didn't matter if I used grffile or not.

But I advise you strongly to avoid spaces in file names or folders: If you switch to another driver (pdflatex, xelatex, ...) or to another system (TexLive, Linux) it can break completly or work only after a syntax change. The time you spend to get arround the problems can be used for better things.

Btw: I also would like to remember that dvips won't include graphicx with absolute pathes or pathes that refer to parent directories (../).

share|improve this answer
    
I works only for \includegraphics{"dir with space/filename with space"}. But it cannot work for a pair of \graphicspath{{"dir with space/"}} and \includegraphics{"filename with space"}. –  xport Jan 7 '11 at 9:45
    
Well I obviously forget in my list "why not to use spaces" the point "or more complicated scenarios involving e.g. \graphicspath". –  Ulrike Fischer Jan 7 '11 at 11:58
add comment

grffile is to allow spaces in images in pdfTeX, not for dvips. Here's some code from the asymptote.sty package that is supposed to deal with spaces in dvips graphics; maybe it will help. Just put it in your preamble.

\makeatletter
\def\Ginclude@eps#1{%
  \message{}%
  \bgroup
  \def\@tempa{!}%
  \dimen@\Gin@req@width
  \dimen@ii.1bp\relax
  \divide\dimen@\dimen@ii
  \@tempdima\Gin@req@height
  \divide\@tempdima\dimen@ii
    \special{PSfile=#1\space
      llx=\Gin@llx\space
      lly=\Gin@lly\space
      urx=\Gin@urx\space
      ury=\Gin@ury\space
      \ifx\Gin@scalex\@tempa\else rwi=\number\dimen@\space\fi
      \ifx\Gin@scaley\@tempa\else rhi=\number\@tempdima\space\fi
      \ifGin@clip clip\fi}%
  \egroup
}
\makeatother
share|improve this answer
    
Thanks for the suggestion +1. It seems like it might have worked, but it didn't work. Even if I included the entire asymptote.sty file. A comment in the code says "% Work around bug in dvips.def: allow spaces in file names." Perhaps spaces are not supported in the path directory? –  denilw Oct 20 '10 at 16:58
3  
@denilw: Not to deprive Will of some reputation, but if his answer didn't solve your problem, you shouldn't accept the answer. You're more likely to get answers if the question doesn't have an accepted answer. –  TH. Jan 7 '11 at 5:03
    
Hi @TH thanks for the tip. I did wait a while before I awarded @Will Robertson the checkmark. I awareded it due to the effort he put forth towards the solution, and I didn't want an acceptance rate that was too low. Due to popular demand (and more importantly a more accurate solution) I have reawarded the checkmark. –  denilw Jan 10 '11 at 23:32
add comment

Your Answer

 
discard

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.