How to ignore missing images when compiling?

There a few options to compile a LaTeX where a image is not available, each with some advantages and disadvantages:

  1. Comment the line of the \includegraphics command. With this option the format of the text obviously change to fill the space left by the deleted (commented) image. Need manual editing of the body text. But is is easy restore the deleted command.

  2. Use \usepackage[demo]{graphicx}. Without editing the body of the document, all the images are black boxes, but if they have a defined absolute size (e.g. width=2cm,height=3cm) the format of text is well maintained. Useful for draft versions were the focus is the text distribution or when a faster compiling is needed. When you obtain the lost image all you need is remove the demo option. In response to luchonacho comments: Using the beamer class or other that load automatically graphicx, you can always provide that option to the document class, and you can do this also when is load manually in more standard classes (e.g, \documentclass[demo]{article}) and in fact is somewhat more practical in this way as you can see this option in first line of code.

  3. Notwithstanding these comments point to another interesting option: draft. You can use also the option in the package graphicx or the document class. Instead of a black block show a framed box with the name of the file image. If the image is available in the hard disk, the box will have the correct size even if this is not showed in \includegraphics. Otherwise, please apply what has been said before for demo, but for save printer the ink of the printer is indeed better.

  4. Replace the image with a obvious fake image always available until obtain the original. the mwe package provides a few figures as example-image-a that should be availables even without load that package and without specifying the path. Run texdoc mwe for more information.

If you are asking to compile the document without having the image but render it anyway from PDF, the obvious solution is extract the image from the PDF, for example editing the pdf with Gimp, or making a screen capture, but you can also do that with a pure LaTeX solution with the page,trim and clim options of \includegraphics, with some like:

\includegraphics[trim=2cm 2cm 2cm 2cm,clip,page=23]{myfigure.pdf} 

(The trim sizes are at left, bottom, right and top, respectively)


First of all, editing should always be possible. The problems start with compiling the file. Normally you should be able to compile and ignore the error output, for example with pdflatex --interaction=nonstopmode. If you want a more general solution either comment them out by hand as Michael suggests or use

\usepackage{comment}
\excludecomment{figure}