Sign up ×
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 tried


But this returns the error

ERROR: Package pdftex.def Error: File
not found.

Are there other options?

share|improve this question
ConTeXt supports this natively. \externalfigure[] just works. Behind the scenes, ConTeXt downloads the file to the luatex cache once, and from then on just reuses the figure. – Aditya Nov 16 '10 at 4:36
do you want to add this as an answer? That way, I can select it. – David LeBauer Nov 16 '10 at 5:07

2 Answers 2

up vote 44 down vote accepted

you could use \write18 and a curl or wget script to grab the image from the web and download it to your directory.

\usepackage{graphicx} % includegraphics command is implemented here



note however, that recent versions of miktex and texlive come with restricted versions of \write18, and it some cases you must pass an option to latex to enable it, as in:

pdflatex --shell-escape test.tex
share|improve this answer
could you please provide example code in your answer? I did not realize that it was possible to use bash code within latex, although I do use Sweave so I can understand the principle. – David LeBauer Nov 15 '10 at 22:04
nice! I guess that this underscores the point that I only need to download the image once in any case. But this approach seems like it would help with portability. – David LeBauer Nov 16 '10 at 3:09
\IfFileExists{image.png}{}{\write18{...}} would help with the only-downloading-once problem. – Will Robertson Nov 16 '10 at 9:06
Could this be done programmatically somehow, maybe with a \renewcommand such that includegraphics can just take the url as an argument? – cboettig Oct 9 '12 at 1:23

Short answer: no. You will need to download the image and use it locally if you want to include it in your document. pdfTeX and XeTeX do not include the necessary code to grab an image from an arbitrary location.

Of course, you can link to an image at at remote location. You can make use of the hyperref package to include a suitable link. You might do this using a bit of text:

\href{}{picture here}

or by downloading a local copy and then pointing to the online version


I note from the comments that LuaTeX does include the necessary library to download a copy of an image itself. That would make inclusion possible directly, but I don't know of a pre-build solution for LuaLaTeX. I guess that would be a separate answer in any case.

share|improve this answer
I am not sure if I understand, it seems to me that your short answer contradicts your second answer. And, could you please provide an example of how can I use hyperref to do this? – David LeBauer Nov 16 '10 at 3:07
@David: I've added a bit more detail – Joseph Wright Nov 16 '10 at 7:07
I'm trying this kind of reference, but it seems to fail - has the relevant functionality been removed? (I'm getting a "some.jpg is missing" error) – blueberryfields May 14 '13 at 17:48

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.