I have tried
\includegraphics{http://www.site.com/path/to/figure.png}
But this returns the error
ERROR: Package pdftex.def Error: File `http://www.website.com/path/to/figure.png' not found.
Are there other options?
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityI have tried
\includegraphics{http://www.site.com/path/to/figure.png}
But this returns the error
ERROR: Package pdftex.def Error: File `http://www.website.com/path/to/figure.png' not found.
Are there other options?
you could use \write18
and a curl or wget script to grab the image from the web and download it to your directory.
\documentclass{article}
\usepackage{graphicx} % includegraphics command is implemented here
\begin{document}
\write18{wget http://www.some-site.com/path/to/image.png}
\includegraphics{image.png}
\end{document}
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
\IfFileExists{image.png}{}{\write18{...}}
would help with the only-downloading-once problem.
– Will Robertson
Nov 16 '10 at 9:06
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{http://somewhere.com/someplace/some.jpg}{picture here}
or by downloading a local copy and then pointing to the online version
\href{http://somewhere.com/someplace/some.jpg}{\incudegraphics{some.jpg}}
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.
(Copying from the comments section)
ConTeXt supports this natively:
http://wiki.contextgarden.net/What_is_ConTeXt
The following:
\externalfigure[http://www.site.com/path/to/figure.png]
just works. Behind the scenes, ConTeXt downloads the file to the luatex cache once, and from then on just reuses the figure.
My additional notes:
ConTeXt (LuaTeX)
. It didn't work when I tried ConTeXt
(pdfTeX)
.
\externalfigure[http://www.site.com/path/to/figure.png]
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