Graphics, Figures & Tables[demo]{graphicx} change color

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
tim4dev
Posts: 4
Joined: Wed Mar 03, 2010 7:45 am

[demo]{graphicx} change color

Post by tim4dev »

I use

Code: Select all

\usepackage[demo]{graphicx}
Are drawn black rectangles.
How to change their color? For example, to rectangles were gray?
Last edited by tim4dev on Thu Mar 11, 2010 8:51 am, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

[demo]{graphicx} change color

Post by gmedina »

Hi,

the demo option is implemented in the file graphics.sty. Search for the files graphicx.sty and graphics.sty in your system (warning: do not modify those files directly); make a copy of each one of them and save the copies (in your working directory or in your local TDS tree, for example) as mygraphicx.sty and mygraphics.sty.

Open the file mygraphicx.sty with a text editor and edit this file as follows:

Replace

Code: Select all

\ProvidesPackage{graphicx}
          [1999/02/16 v1.0f  Enhanced LaTeX Graphics (DPC,SPQR)]
with

Code: Select all

\ProvidesPackage{mygraphicx}
          [1999/02/16 v1.0f  Enhanced LaTeX Graphics (DPC,SPQR)]
Replace

Code: Select all

\DeclareOption*{\PassOptionsToPackage\CurrentOption{graphics}}
\ProcessOptions
\RequirePackage{keyval,graphics}
with

Code: Select all

\DeclareOption*{\PassOptionsToPackage\CurrentOption{mygraphics}}
\ProcessOptions
\RequirePackage{keyval,mygraphics}
Save the changes and close the file. Now open mygraphics.sty and do the following changes:

Replace

Code: Select all

\ProvidesPackage{graphics}
          [2009/02/05 v1.0o  Standard LaTeX Graphics (DPC,SPQR)]
with

Code: Select all

\ProvidesPackage{mygraphics}
          [2009/02/05 v1.0o  Standard LaTeX Graphics (DPC,SPQR)]
Replace

Code: Select all

\DeclareOption{demo}{%
  \AtBeginDocument{%
    \def\Ginclude@graphics#1{%
      \rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}%
      {\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}}}
with

Code: Select all

\DeclareOption{demo}{%
  \AtBeginDocument{%
    \def\Ginclude@graphics#1{%
      \color{gray}\rule{\@ifundefined{Gin@@ewidth}{150pt}{\Gin@@ewidth}}%
      {\@ifundefined{Gin@@eheight}{100pt}{\Gin@@eheight}}}}}
Save the changes and close the file.

In the preamble of your .tex document use

Code: Select all

\usepackage[demo]{mygraphicx}
instead of

Code: Select all

\usepackage[demo]{graphicx}
Perhaps there's an easier way, but I cannot think about it right now.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
tim4dev
Posts: 4
Joined: Wed Mar 03, 2010 7:45 am

[demo]{graphicx} change color

Post by tim4dev »

Thanks.

I made:

Code: Select all

\usepackage{ifthen}

\newboolean{make-with-pic}
\setboolean{make-with-pic}{true}
%\setboolean{make-with-pic}{false}


\newcommand{\MyPic}[4]{
\begin{figure}[htp]
 \centering
 \ifthenelse{\boolean{make-with-pic}}
   {\includegraphics[width=1.0\textwidth,totalheight=0.45\textheight,keepaspectratio=true]{#1}}
   {\includegraphics[height=1cm,width=1cm]{dummy.png}}
 \caption[#2]{#3}
 \label{#4}
\end{figure}
}

Post Reply