0

This post is sort of an extension to the question posed in Color an Example Image but Leave the Default Drab

Consider the code

\documentclass{article}
\usepackage{xcolor,graphicx}
\usepackage{caption}

\makeatletter \define@key{Gin}{color}{\def\Gin@color{#1}}

\setlength{\fboxsep}{0pt} \let\oldincludegraphics\includegraphics \renewcommand{\includegraphics}[2][]{% \ifnum\pdfstrcmp{#2}{example-image}=0% \begingroup \setkeys{Gin}{color=red,#1} % Sets default color to be red \colorbox{\Gin@color}{\phantom{\oldincludegraphics[#1]{#2}}}% \endgroup \else \oldincludegraphics[#1]{#2}% \fi } \makeatother

\begin{document} \begin{figure}[!htb] \centering \includegraphics[width=10em,height=13em]{example-image} \captionsetup{labelformat=empty} \vskip 8pt \caption{\textbf{\scshape{\large Red Figure}}} \end{figure}

\begin{figure}[!htb] \centering \includegraphics[width=10em,height=13em,color=blue]{example-image} \captionsetup{labelformat=empty} \vskip 8pt \caption{\textbf{\scshape{\large Blue Figure}}} \end{figure}

\begin{figure}[!htb] \centering \includegraphics[width=10em,height=13em]{example-image-a} \captionsetup{labelformat=empty} \vskip 8pt \caption{\textbf{\scshape{\large How to Color Shade, Say Green, Figure A?}}} \end{figure} \end{document}

which produces the output

enter image description here

I would like to add some (green) color shading to the last image (example-image-a). However, when I replace \includegraphics[width=10em,height=13em]{example-image-a} with \includegraphics[width=10em,height=13em,color=green]{example-image-a}, I get the same example-image-a as shown.

This is perhaps, not surprising, because if color=green worked in this case, I suppose the "A" with its associated lines might be obliterated.

QUESTION: Is it possible, and if so, how may I add some (green) color shading to the example-image-a figure so that the image is colorized, yet the A with its associated lines are still visible? Might this involve some sort of a colorized transparent veneer?

Thank you.

DDS
  • 8,816
  • 4
  • 9
  • 36

1 Answers1

1

well basically you only have to place a semi transparent rule over the image:

\documentclass{article}
\usepackage{xcolor,graphicx}

\usepackage{transparent} \begin{document}

\begin{figure}[!htb] \centering \includegraphics[width=10em,height=13em]{example-image}\llap{\texttransparent{0.5}{\color{green}\rule{10em}{13em}}}

\caption{How to Color Shade, Say Green, Figure A?} \end{figure}

\end{document}

enter image description here

Ulrike Fischer
  • 327,261