# Placeholder for figure/includegraphics

Is there a command that I can use as a placeholder for \includegraphics? I want to use such a placeholder to add the original graphics later.

-
You may create a dummy.jpg (or dummy.eps) and use this dummy graphic until you have your original one. –  knut Feb 11 '12 at 14:35
See tex.stackexchange.com/a/30624/4427 for having the demo option not printing big blobs. –  egreg Feb 11 '12 at 15:15
@egreg: can you post that one as an answer to this one? I may accept that one. –  nimcap Feb 11 '12 at 15:38

todonotes provides the \missingfigure command, precisely designed for this case

\documentclass{article}
\usepackage{todonotes}

\begin{document}

\missingfigure[figwidth=6cm]{Testing a long text string}

\end{document}


-

I dont't like the demo option of the graphicx package, because one get some ugly black boxes in the document. And if you want to make a test print you waste a lot of ink and maybe your reviser is wondering about. So I created my own demo mode and just include an empty rectangle with the same size of the original picture. If I want to use the original pictures I comment the definition out and all the pictures will be inserted. For this it is necessary to use the picins package.

\documentclass{book}
\usepackage{picins}
\usepackage{graphicx}

\makeatletter
\def\Ginclude@graphics#1{%
\parpic(\Gin@@ewidth,\Gin@@eheight)[d]{#1}\picskip{0}}%
\makeatother

\begin{document}
\begin{figure}
\centering
\includegraphics[width=8cm,height=5cm]{myPictureName.png}%
\caption{My Picture}
\end{figure}
\end{document}

-
Where did you get picins? It doesn't seem to be a standard package. –  qubyte Feb 11 '12 at 14:20
@MarkS.Everitt Used to be standard but was removed from TL, I think, for license reasons. –  Joseph Wright Feb 11 '12 at 14:24
At ctan.org/pkg/picins you can see that picins is standard in MiKTeX (I use MiKTeX) but not in TeXLive. You should install it manually. –  Holle Feb 11 '12 at 14:25
@Holle: Good to know. Could you put the link into the answer though? I think it's a good thing to have there for completeness. –  qubyte Feb 11 '12 at 14:50
@Yiannis Please keep in mind that this approach was intended by the fact that there were no pictures to insert and that we don't want to use the demo mode of the graphicx package. So you don't know the size of the pictures. If you already have the pictures and you don't want to show them in the document you should use the draft option of you documentclass. –  Holle Feb 11 '12 at 18:12

If you need individual figures to be omitted rather than all of them, you first copy a dummy figure (called foo here) to your figures path, then use as:

\includegraphics[draft]{foo}


It will display something like:

It will also save ink, and you can use \includegraphics syntax as it is, you just need to replace foo and remove draft from command.

-
I am not sure if the bounding-box computations are reliable. I had some problems with the replacement of default sized boxes for the draft mode graphics. By the way, for every picture you can also use \usepackage[draft]{graphicx}. Turkce gormek ayrica sasirtici :) –  percusse Feb 13 '12 at 13:56
@percusse: actually, although I almost never use default sizes, I omitted width, height arguments in my example. selamlar efendim :) –  nimcap Feb 13 '12 at 19:28

Either load the graphicx package with the demo option or replace \includegraphics by, say, \rule{2cm}{2cm}.

-
IIRC, \includegraphics[demo,width=<..>,height=<..>]{dummy} should work as well, i.e. demo used locally. –  Martin Scharrer Feb 11 '12 at 13:39
@Martin: I get ! Package keyval Error: demo undefined. –  math Nov 5 '12 at 14:18
To avoid the black box of \rule{2cm}{2cm} but to keep the simplicity, you can draw just two or three edges of the box with \rule{.1pt}{2cm} \rule{2cm}{.1pt} \rule{.1pt}{2cm} –  Andrew Martin Dec 15 '14 at 14:12

You can do without additional packages: just load graphicx with the demo option and do as explained in this answer; I repeat the code for completeness:

\usepackage[demo]{graphicx}

\makeatletter
\AtBeginDocument{%
\def\Ginclude@graphics#1{%
\begingroup\fboxsep=-\fboxrule
\fbox{\rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}{0pt}%
\rule{0pt}{\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}\endgroup}}
\makeatother


Just remove the demo option and comment the additional code when you want to include the real graphic files.

This will produce framed rectangles with the specified width and height, but using a predefined dimension when width= and height= are not specified in the options to \includegraphics.

Another strategy is to load graphicx with the draft option, that will read the graphic files for getting their dimensions and print a framed rectangle with the file name in their place

\usepackage[draft]{graphicx}


As always, beware of file names with spaces: enclosing the name between double quotes should avoid problems.

-

Inspired by Holle's answer (avoid a big black toner hungry box), here is one with pgf. The pgf package has a draft option. With it:

\documentclass{article}
\usepackage[draft]{pgf}

\begin{document}

\begin{figure}[ht]
\centering
\begin{pgfpicture}
\pgftext{\pgfimage[width=5cm,height=4cm]{scratch.png}}
\end{pgfpicture}
\end{figure}

\end{document}


where scratch.png is your image. With draft as an option to the pgf package this simply looks like a box with the file name:

Without the draft option, the image is placed as expected.

-
Doesn't this just draws a box of X by Y? One would ideally need to be able to measure the actual image and print the box to the resulting dimension (i.e, if only width or height is specified, keepaspectratio etc). –  Yiannis Lazarides Feb 11 '12 at 16:28
I agree. It defaults to a 1cm by 1cm box. Perhaps it can be improved, but it's already a peripheral answer. –  qubyte Feb 11 '12 at 16:37

If you want to "hide" the entire picture, but reserve the space, you could use the following lines:

\usepackage{xcolor,graphicx}
...
\color{white}
\includegraphics[draft , ...]{picture}
\color{black}

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it) or type Ctrl+K. –  henrique May 9 '12 at 15:38