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 want to specify path-to-image\image.png but for obvious reasons that will not work because \... is interpreted as a command. How do I include a path to my image? (I'm on Windows 7).

\documentclass[12pt]{article}
\usepackage{graphicx}

\begin{document}
\includegraphics[scale=1]{Data Analysis Files\InteractionPlotforTransLog10(X+1)Count.png}
\end{document}

I also tried reversing the slash and using the grffile package with the space option as follows:

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage[space]{grffile}

\begin{document}
\includegraphics[scale=1]{Data Analysis Files/InteractionPlotforTransLog10(X+1)Count.png}
\end{document}
share|improve this question
    
Possible duplicate: tex.stackexchange.com/questions/15387/… –  doncherry Jun 5 '11 at 14:26
    
Possible duplicate: Paths and Linux/Windows slash conventions –  Danie Els Jun 5 '11 at 14:46
    
Forgive me, I saw some of those previous threads but I tried a number of permutations of the solutions but couldn't get it to work including reverse the slash, invoke grffile pkg with space option, but no luck still...I would be grateful if someone would suggest an explicit solution... –  ptrcao Jun 5 '11 at 14:50
    
The source of problem is the path with spaces, see tex.stackexchange.com/questions/8422/… –  xport Jun 5 '11 at 15:00
    
@ptrcao Put quotes around the name: "Data Analysis Files/InteractionPlotforTransLog10(X+1)Count.png" –  egreg Jun 5 '11 at 15:02

2 Answers 2

up vote 3 down vote accepted

Try:

\documentclass[12pt]{article}

\usepackage{a4wide}
\usepackage{graphicx}

\begin{document}
\includegraphics[scale=1]{\string"Data Analysis Files\string\InteractionPlotforTransLog10(X+1)Count"}
\end{document}
share|improve this answer
    
! LaTeX Error: File `"Data Analysis Files\InteractionPlotforTransLog10(X+1)Count"' not found. –  ptrcao Jun 5 '11 at 14:57
    
I work with Ubuntu and it works for me. Sorry. Is the name of the file Data Analysis Files\InteractionPlotforTransLog10(X+1)Count –  Marco Daniel Jun 5 '11 at 15:01
    
This one works for me, too (MiKTeX 2.9 on Win7). ...Count.png"} doesn't work; ...Count".png} and ...Count"} (Marco's) work. –  doncherry Jun 5 '11 at 15:16
    
The path is "Data Analysis Files\" The filename is "InteractionPlotforTransLog10(X+1)Count" Is that what you meant? –  ptrcao Jun 5 '11 at 16:52
1  
@ptrcao: Great, I'm glad your problem could be helped. A tip: you can use backticks ` to mark your inline code in comments as well as in questions and answers. It just makes it much easier to read. –  doncherry Jun 5 '11 at 17:17

An alternative that works is to use the short DOS path name. In the DOS prompt window enter dir /x to obtain the short names. Use \detokenize to get around the tildes ~ in the file names.

\includegraphics{\detokenize{DATAAN~1/INTERA~1}}

I normaly use a Python script to get needed short names by copying an exsiting path into the script below.

import win32api

#Copy and paste an existing path here
path = r'C:\Users\dnjels\Documents\DE-LaTeX\Temp\Tests\Data Analysis Files\InteractionPlotforTransLog10(X+1)Count.png'

shortpath = win32api.GetShortPathName(path)
shortpath = shortpath.replace('\\','/')

print  shortpath
print  r'\detokenize{' + shortpath + '}'

This will give (on my system)

C:/Users/dnjels/DOCUME~1/DE-LaTeX/Temp/Tests/DATAAN~1/INTERA~1.PNG

share|improve this answer
    
Thanks Danie, apparently the solution was simpler than I thought but the nobel effort has been recognised with an upvote. I'm probably not knowledgeable enough to get my head around this yet, but someone else will find it useful, I'm sure :) –  ptrcao Jun 5 '11 at 17:12

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.