30

I know that includegraphics can be used in Latex to include images into the document, but how can I specify a path for that file?

\includegraphics[]{picture-name}

Instead of asdd.jpg I want to specify C:\Documents and Settings\Nina\asdd.jpg, because that's where the image is.

11
  • There is a LaTeX-specific page in the StackExchange network. Consider that one. Commented Apr 9, 2011 at 15:36
  • And what's with that {imgs/RTS}? where it is located? i need the image asdd.jpg from C:\Documents and Settings\Nina folder. How can i specify this??
    – qwerty
    Commented Apr 9, 2011 at 15:43
  • @qwerty: Rather than "answering" your question, you should edit the original question to include the additional information. (You may have to register at tex.se in order to do so.)
    – lockstep
    Commented Apr 9, 2011 at 15:46
  • But tell me, how can i specify that folder and the image wihtin that folder?
    – qwerty
    Commented Apr 9, 2011 at 15:47
  • I just told you - you place the full path in the {image} field. Works for me.
    – TomMD
    Commented Apr 9, 2011 at 15:49

6 Answers 6

38

You need to write the \ as / because (La)TeX follows the Unix style (which is also used for WWW addresses). Also the spaces in the filename are a problem. You can load the grffile package with the space option to make things easier as mentioned by Herbert in How to include graphics with spaces in their path?. If it wouldn't be for the \vs./ your question would be a duplicate of it. Alternatively try to enclose the file base in { } as explained in \includegraphics: Dots in filename.

% Preamble
\usepackage{graphicx}
\usepackage[space]{grffile}
%...
% Document
\includegraphics{C:/Documents and Settings/Nina/asdd.jpg}
7

You may use following command:

\graphicspath{{<your path>}}

Also see this and this.

5

I had no issues when I put the path directly where the picture name belongs, for example:

\begin{figure}[t]
  %\epsfig{figure=RTS.eps,height=5.5cm}
  \includegraphics[height=5.5cm]{imgs/RTS}
  \caption{The run-time system intercepts calls that cross protection domains, allocating
  new stacks, updating memory permissions and tracking old stack and credential values
  for use once the callee returns.}
  \label{fig:rts}
\end{figure}

In the above "imgs" is the immediate (local) directory and RTS is the file minus the extension. I have "RTS.pdf" and "RTS.eps" files in that directory containing my image.

pslatex or pdflatex will use the correct file for their respective needs.

EDIT: And yes, if I place the full path (/home/username/..., the Linux equal of C:\Documents and Settings\...)instead of just a relative path (the immediate sub-directory of imgs) then it also works fine.

If you're still having trouble then perhaps you need to escape the spaces in your path: C:\Documents\ and\ Settings\...

3

If the images are in the same folder, use \graphicspath{}

0
0

There are a number of options. Say tex files are in folder "/my/report/" and your graph "graph.jpg" is in "/my/report/graphs/"

Option 1 : use the full path : \includegraphics{/my/report/graphs/graph.jpg}

Option 2 : use a relative path : \includegraphics{../graphs/graph.jpg}

Option 3 : Use "graphics path" as in this website https://texblog.org/2017/12/05/the-path-to-your-figures/

The weakness of the first : move your files folder, and the tex file will fail. The weakness of the third : redefining variables is a pain. => I prefer the second.

*p.s. there's something odd with the relative path : since the form "../" means "one level up in the directory structure", it seems to point to the wrong location as far as I'm concerned. It should be "./graphs", not ../graphs"

To spell this out, if I have a folder "/texts" an subfolder "/texts/graphs", and am compiling my tex files in /texts, I'd expect to point to graphs by "./graphs" But that's the way it is : "../graphs" is the form to use.*

0

I use double periods to specify the path. \begin{figure}[h!] \centering \includegraphics[width=0.8\textwidth]{../../Pictures/stong2} \caption{On top of a mountain}\label{fig:st} \end{figure}

If you are not sure about the path, try right click on the image and click properties. It'll show the folder path.

You must log in to answer this question.