194

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.

5
  • 1
    You may create a dummy.jpg (or dummy.eps) and use this dummy graphic until you have your original one.
    – knut
    Feb 11, 2012 at 14:35
  • 5
    See tex.stackexchange.com/a/30624/4427 for having the demo option not printing big blobs.
    – egreg
    Feb 11, 2012 at 15:15
  • @egreg: can you post that one as an answer to this one? I may accept that one.
    – nimcap
    Feb 11, 2012 at 15:38
  • Related: Example images in LaTeX? Mar 30, 2018 at 9:11
  • Wow, not a single tikz answer!
    – beldaz
    May 25, 2018 at 21:04

12 Answers 12

186

It's 2018 now, and this has become very easy.

Simply:

\includegraphics[width=\textwidth]{example-image-a}

The mwe package needs to be installed for this (but it doesn't need to be included in the preamble). If using MiKTex e.g., it will offer to install this package when the document is built.


There are other placeholder images available as well.

Example document from another StackExchange answer:

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}

\begin{document}

\noindent\includegraphics[width=3cm]{example-image-a}\qquad
\includegraphics[width=3cm]{example-image-golden}\qquad
\includegraphics[width=3cm]{example-grid-100x100pt}

\noindent\includegraphics[height=5cm]{example-image-b} 

\noindent\includegraphics[scale=0.5]{example-image-c} 

\noindent\includegraphics[width=3cm]{example-image} 

\end{document}

enter image description here

4
  • 6
    I wish this could be somewhere near the top. :-)
    – Brett
    Sep 10, 2018 at 17:54
  • Compilation always fails when [draft] is not given. Can you explain why?
    – Patrick
    Apr 13, 2021 at 17:28
  • @Patrick: Not without context. Kindly post a proper question, someone might help then.
    – Tomas
    May 31, 2021 at 17:15
  • @Patrick: perhaps you're using \includegraphics[draft][width=3cm]{example-image-a}, whereas it should be \includegraphics[draft,width=3cm]{example-image-a}. That is, use only one pair of block brackets. For others: the draft option will only draw a bounding box instead of the actual image (to save ink/toner).
    – Bart
    Jul 27, 2022 at 13:10
78

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}

Result of the above code

5
  • this doesn't work for me with \includegraphics
    – G M
    Mar 27, 2017 at 13:24
  • 5
    I don't understand what you mean. I don't use \includegraphics here.
    – Evpok
    Mar 27, 2017 at 14:25
  • yes exactly so you have to remove \includegraphics and later re-insert it
    – G M
    Mar 27, 2017 at 15:10
  • I expected something to use with includegraphics like the others answers
    – G M
    Mar 27, 2017 at 15:23
  • 7
    I don't see why. This is a placeholder, you just replace it with the actual content when you get it. it is no different from e.g. removing [draft] and putting the actual path in the accepted solution.
    – Evpok
    Mar 27, 2017 at 20:40
66

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:

enter image description here

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.

2
  • 8
    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, 2012 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, 2012 at 19:28
27

It's 2018 now, and this has become even more fun.

Simply:

\includegraphics[width=\textwidth]{example-image-duck}

The duckuments package needs to be installed for this. If using MiKTex e.g., it will offer to install this package when the document is built.

Example document from another StackExchange answer:

\documentclass[12pt,a4paper]{article}
\usepackage{graphicx}

\usepackage{duckuments}

\begin{document}

\noindent\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}
\includegraphics[width=3cm]{example-image-duck}

\end{document}

enter image description here

(This post may have been inspired by Tomas answer :)

25

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

4
  • 9
    IIRC, \includegraphics[demo,width=<..>,height=<..>]{dummy} should work as well, i.e. demo used locally. Feb 11, 2012 at 13:39
  • 17
    @Martin: I get ! Package keyval Error: demo undefined.
    – math
    Nov 5, 2012 at 14:18
  • 3
    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} Dec 15, 2014 at 14:12
  • @vowel-house-might this is brilliantly simple ! Thanks. Just wanted to highlight for other readers that you cannot get 4 lines with this method (I have tried). But 3 works very well. Also note that the horizontal line cannot be \linewidth long, as the others no longer have space. So just put the numbers manually. May 23 at 12:17
25

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.

enter image description here

\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}
7
  • 2
    Where did you get picins? It doesn't seem to be a standard package.
    – qubyte
    Feb 11, 2012 at 14:20
  • 4
    @MarkS.Everitt Used to be standard but was removed from TL, I think, for license reasons.
    – Joseph Wright
    Feb 11, 2012 at 14:24
  • 2
    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, 2012 at 14:25
  • 1
    @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, 2012 at 14:50
  • 1
    @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, 2012 at 18:12
21

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.

11

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:

enter image description here

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

2
  • 1
    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). Feb 11, 2012 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, 2012 at 16:37
10

A better version to hide the entire picture but keep the space is to use the phantom command

\phantom{\includegraphics[...]{picture}}

This avoids white text, could for example be selected in the pdf.

PS: not enough repo to comment on Dennis' answer.

8

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}
1
3

You can use the package draftfigure to switch off and modify the display of figures:

    \documentclass{article}
    \usepackage[
      %various options globally available
    ]{draftfigure}
    \usepackage{caption}
    \setkeys{Gin}{width=.5\linewidth}%only for demonstration
    \begin{document}
    \begin{figure}[htb]
     \centering
     \setkeys{draftfigure}{content={white box}}
      \includegraphics[draft]{example-image-a}
      \caption{A}\label{A}
     \setkeys{draftfigure}{filename=true}
      \includegraphics[draft]{example-image-b}
      \caption{B}\label{B}
     \setkeys{draftfigure}{content={another white box}}
      \includegraphics[draft]{example-image-c}
      \caption{C}\label{C}
    \end{figure}

    \begin{figure}[htb]
     \centering
     \setkeys{draftfigure}{content={white box}}
      \includegraphics[draft]{example-image-a}
      \caption{A}\label{A1}

     \setkeys{draftfigure}{filename=true,
     style={tt},position={right}}
      \includegraphics[draft]{example-image-b}
      \caption{B}\label{B1}

     \setkeys{draftfigure}{content={hidden image},
       style={rm},filename=false,position={center}}
      \includegraphics[draft]{example-image-c}
      \caption{C}\label{C1}
    \end{figure}
    \end{document}

examples 1 examples 2

3

I like the simplicity of https://gist.github.com/dpgettings/9635856 (not mine, so credit to the author dpgettings):

\newcommand{\dummyfig}[1]{
  \centering
  \fbox{
    \begin{minipage}[c][0.33\textheight][c]{0.5\textwidth}
      \centering{#1}
    \end{minipage}
  }
}

which can be used as:

\begin{figure*}[h]
  \dummyfig{Dummy Figure Label} 
  \caption{Dummy figure caption}
  \label{fig:dummy}
\end{figure*}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .