0

I am trying to insert an image in latex document. But I am getting an error. I am using the following commands with \usepackage{graphicx}

\graphicspath{ {/Users/richie/Downloads} }
\includegraphics{Log.png}

I am attaching my code and error.

Code Error

  • 1
    Which error do you get? How do you compile your document, with pdflatex or another engine? – user36296 Jan 18 at 11:03
  • Are you sure you are using pdfLaTeX (or LuaLaTeX, XeLaTeX) and not the original LaTeX in DVI Mode? In DVI Mode PNGs are not supported. Please post the error message(s) in question. – Martin Scharrer Jan 18 at 11:40
  • Also {/Users/richie/Downloads} doesn't sound that right. You are under MS Windows, right? Try e.g {c:/Users/richie/Downloads/}. – Martin Scharrer Jan 18 at 11:41
  • @Martin Scharrer Please see my edited question. – prashant sharma Jan 18 at 16:30
  • @samcarter Please see my edited question. – prashant sharma Jan 18 at 16:31
1

According to the documentation for graphicx, \graphicspath expects a list of names in the same format as that required for the LaTeX \input@path. As the LaTeX source tells us

[E]ither dir should be defined as a macro with argument delimited by space, or it should just expand to a directory name, including the final directory separator, so that it may be concatenated with the filename. This means that for UNIX-like syntax, each dir should end with a slash, /.

You are missing the final slash in the directory. That at least is one possible reason why the file will not be found. Of course, if you are using Windows you have, as Martin Scharrer pointed out in his comment, another problem too.

  • From the screenshots I'd say it is mac and not windows, so I think you nailed the problem – user36296 Jan 18 at 17:02
  • 1
    I thought it was probably Mac. I think the documentation of graphicx could be improved on this point: it would be more useful for most users to simply be told to add the final slash, rather than be left to root around in source2e for information about \input@path ... especially since the error message does not help much. – Paul Stanley Jan 18 at 17:06
  • The author of graphicx might not have considered the possibility, that people would read the documentation :) – user36296 Jan 18 at 17:14
0

You need to add an slash / at final part of the path.

This works for me:

\graphicspath{{/home/rogelioprieto/Downloads/}}

for you:

\graphicspath{ {/Users/richie/Downloads/} }

This is an example in documentation:

enter image description here

  • 2
    Isn't this exactly what the already existing answer by @Paul Stanley said? – user36296 Jan 18 at 21:41
  • yeah, but when I've read for first time, didn't appeared @Paul Stanley answer! – Rogelio Prieto Jan 19 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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