I have a long document (800 pages) with lots of pictures (300 pictures). I have to produce a version of this document without the pictures (for copyright reasons). The solution I have found so far is to use the draft mode of the graphicx package.

This solution is not fully satisfactory because it replaces the picture by a white rectangle with the name and location of the picture inside.

I would like to have only a white rectangle (of the same size as the picture, with a thin frame), but without any text inside.

Does anyone have a clue?


Well then, just patch graphicx to not output the text:



  \GenericWarning{}{Failed to patch \protect\Gin@setfile}}




This code makes use of the etoolbox package.

  • I'm not that familiar with the \patchcmd instruction: Does it matter for the command's operation that the command \Gin@setfile is located in the file graphics.sty rather than in graphicx.sty? (The former style file is loaded by the latter...) Separately, might it be safer to replace the assignment \edef\@tempa{#3}, in the preceding line of the code for the \Gin@setfile command, with \edef\@tempa{}? Please advise.
    – Mico
    Oct 2 '11 at 15:48
  • @Mico: This command works at macro level, not package level. You can read the etoolbox manual entry on this command. The \@tempa line can be left as it is, as it won't produce any side effects. Oct 2 '11 at 16:00
  • I guess my thought was that defining \@tempa to be empty, rather than have it contain the filename string, might be less intrusive than obliterating the next command. However, that's pure speculation on my part.
    – Mico
    Oct 2 '11 at 16:12
  • Thanks so much, this additional explanation is most useful.
    – Mico
    Oct 2 '11 at 16:31
  • @Mico: Sorry, my last statement was incorrect :-S Yes, defining \@tempa to an empty value would work. Oct 2 '11 at 16:34

My attempt was to redefine \includegraphics:

\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{letltxmacro}% http://ctan.org/pkg/letltxmacro
\usepackage{xparse}% http://ctan.org/pkg/xparse
\usepackage{graphicx}% http://ctan.org/pkg/graphicx

\RenewDocumentCommand{\includegraphics}{O{} m}{% \includegraphics[..]{...}


  \oldincludegraphics[height=3cm]{tiger} \quad 
  \includegraphics[height=3cm]{tiger} \quad
  \caption{This is a tiger}


Remove all figures

In the above example, the three images use (i) the original \oldincludegraphics command, followed by (ii) the newly redefined \includegraphics command, followed by (iii) an \fbox{\phantom{\oldincludegraphics{...}}} without the proper \fboxsep set, merely as an illustration of what modification does. The grouping (via \begingroup and \endgroup) within \includegraphics makes sure that setting \fboxsep=-\fboxrule is only local.

letltxmacro provides an effective means to store (or copy) commands that have optional arguments (in this case, the original \includegraphics from the graphicx package), while xparse provides an easy means for specifying commands with (possibly intermixed) optional parameters through \RenewDocumentCommand.

  • 1
    You need to set \fboxsep to zero, or the frame will be slightly larger than the image. Oct 2 '11 at 15:42
  • I just used \fbox as an illustration, nor do I use the draft option of graphicx. I don't think the OP will use \fbox.
    – Werner
    Oct 2 '11 at 15:50
  • Very nice answer (I would have put the \fbox in the new command \includegraphics) ! Thanks a lot !
    – Colas
    Oct 3 '11 at 6:08
  • @Colas: So by "white rectangle" you mean \fbox filled with blank space equivalent to the original picture and not just a white rectangle with no border. Either way, I'll update my answer accordingly, for completeness. It actually makes more sense now.
    – Werner
    Oct 3 '11 at 6:11
  • 1
    @Colas: \begingroup is the same as \bgroup or {. Similarly, \endgroup is the same as \egroup or }. These macros define the scope of certain changes within your code. For example, using \renewcommand within a group makes the change local, reverting back to the original definition after the end of the group. I've also updated my code to use a more appropriate \fboxsep; -\fboxrule in this case.
    – Werner
    Oct 6 '11 at 17:59

For a quick hack, you can edit graphics.sty (in my case, it is /usr/share/texmf-texlive/tex/latex/graphics/graphics.sty) and find where is filename written inside the rectangle (here, it is line 223, containing \rlap{ \ttfamily\expandafter\strip@prefix\meaning\@tempa}%). Comment it out, that's it.

  • 14
    Always edit a copy of the original file, moved to a different location, rather than editing anything in the 'managed' TeX tree.
    – Joseph Wright
    Oct 2 '11 at 15:38
  • Admittedly; I was thinking of someone who needs to send the file away quickly, and will revert the change back right afterwards. The answer with etoolbox is much better.
    – eudoxos
    Oct 2 '11 at 15:41

You can use the package draftfigure to get the same result and modify the display of the switched off figure:




\setdf{content={This figure is switched off.}}


enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.