# How to insert custom text in place of figure

I would like to replace some figures in a document with a black frame of the same size as the figure, such as that which you get when using \includegraphics in draft mode. However, this places the name of the figure file inside the framed box. Is there a way to replace this text with centered text stating
Figure removed due to copyright restrictions?

-

A suggestion can be the combination of collectbox, adjustbox and tikz.

I tried to avoid TikZ but I wasn't able to create the red rectangle with adjustbox.

The code provides two things:

1. A switch do print the image or the copyright information. You can choose by \copyrightimagefalse or \copyrightimagetrue.
2. Instead of using includegraphics you must use \copyrightimage to work with the previous switch.

The Code

\documentclass{article}
\usepackage{mwe}% or load ’graphicx’ and ’blindtext’ manually
\usepackage{xcolor}
\usepackage{collectbox}
\usepackage{tikz}
\collectbox{%
\tikz[outer sep=0pt]\node[fill=red!20,minimum height=\totalheight,minimum width=\width]{%
\smash{\parbox{\width}{\centering\large\bfseries Figure removed due to copyright restrictions}}
};%
\else
\BOXCONTENT
\fi%
}

\begin{document}
\begin{figure}[!ht]
\centering
\end{figure}
\blindtext

\begin{figure}[!ht]

Thanks for your suggestion. However, I cannot seem to get this code working, even if I simply copy-and-paste it and change only the image file. pdfLatex keeps on complaining that \copyrightimage is an undefined control sequence: Undefined control sequence. \\copyrightimage ...ENT \fi }{\adjincludegraphics [#1]{#2}} ￼l.24 \copyrightimage[width=0.48\linewidth]{dice} ? Could you please confirm if the code works as is? Thanks again... –  Miguel May 20 '12 at 17:11
Thanks - the code now runs! But the box is too wide and shifted to the right (lies outside of the text margins when the image has width = \textwidth). Compare: \begin{figure}[!ht] \centering \includegraphics[draft, width=\textwidth]{some-image} \end{figure} \blindtext versus \begin{figure}[!ht] \centering\copyrightimagetrue \copyrightimage[width=\textwidth]{some-image} \end{figure} \blindtext –  Miguel May 21 '12 at 7:13
@Miguel: You use \includegraphics instead of \copyrightimage. As I wrote I defined a new command instead of redefining includegraphics –  Marco Daniel May 21 '12 at 18:32