TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
Use “default” figure if file is missing?

I use LaTeX to take notes during my math classes. When the professor draws an image, I jot it down quickly in a notebook and include it later.

Currently I add a \includegraphics{file} line and then comment it out. This way the code compiles, but I still remember where the image goes. Sometimes, however, I forget to comment the line out.

What I would prefer is a command that looks for a file, displays it if found, and if not displays a message instead ("Placeholder for file"), rather than halting compilation.

Is there any way to do this?

share|improve this question

migrated from stackoverflow.com Aug 29 '12 at 3:14

This question came from our site for professional and enthusiast programmers.

marked as duplicate by Werner, Gonzalo Medina, doncherry, Tom Bombadil, Marco Daniel Aug 29 '12 at 9:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

You could use the [demo] option to the graphicx package. – Peter Grill Aug 29 '12 at 3:25
@PeterGrill sounds like the answer to me :) – cmhughes Aug 29 '12 at 3:27
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Aug 29 '12 at 3:37

You could use the [demo] option to the graphicx package which will allow you to use the \includegraphics{} command with files that do not yet exist -- this will save you form having to coment them out. Then once you have the graphic files you could simply remove the [demo] option.

Another option would be to use \IfFileExists to check that the file exists and use the \missingfigure from the todonotes package:

enter image description here

If you don't want to use an additional package you could just draw your own symbol to represent the missing figure.

Further Enhancements:

  • This does require that you specify the exact file name. This could be enhanced to duplicate the behavior of the \includegraphics package.



        \missingfigure[figwidth=7.0cm]{Missing #2}%

share|improve this answer