How to replace all pictures by white rectangles?
Well then, just patch graphicx
to not output the text:
\documentclass{article}
\usepackage[draft]{graphicx}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\Gin@setfile}{\rlap}{\@gobble}{}{%
\GenericWarning{}{Failed to patch \protect\Gin@setfile}}
\makeatother
\begin{document}
\noindent\includegraphics[width=\textwidth]{tiger}
\end{document}
This code makes use of the etoolbox
package.
My attempt was to redefine \includegraphics
:
\documentclass{article}
\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
\LetLtxMacro{\oldincludegraphics}{\includegraphics}
\RenewDocumentCommand{\includegraphics}{O{} m}{% \includegraphics[..]{...}
\begingroup\setlength{\fboxsep}{-\fboxrule}%
\fbox{\phantom{\oldincludegraphics[#1]{#2}}}\endgroup%
}
\begin{document}
\lipsum[1-2]
\begin{figure}
\centering
\oldincludegraphics[height=3cm]{tiger} \quad
\includegraphics[height=3cm]{tiger} \quad
\fbox{\phantom{\oldincludegraphics[height=3cm]{tiger}}}
\caption{This is a tiger}
\end{figure}
\lipsum[3-5]
\end{document}
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
.
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.