3

I am creating a beamer presentation using the beetle color theme (gray background). I am loading eps images that do not have a white background layer and would like to add one. I do not want to edit all the images to add a white layer to image file. How can I add a white layer, with the same size and position, to serve as a background?

Steven C. Howell
  • 587
  • 1
  • 7
  • 18
  • 3
    Probably with TikZ? Something like \begin{tikzpicture}\node[inner sep=0, fill=white] {\includegraphics{pic.eps}};\end{tikzpicture} – Tom Bombadil Nov 10 '15 at 19:10
  • Can you make one of the images available for download and add a link here? – Ian Thompson Nov 10 '15 at 21:48
  • An example showing how you are using them would encourage answers. Much easier than starting from scratch and trying to guess. Don't include the extension as @TomBombadil suggests, though. Let LaTeX figure out the extension. That way, if you use pdfLaTeX, it will work and, after the first compilation, LaTeX will automatically use the existing converted file. (Obviously, if you don't use pdfLaTeX, this is less important, but it it best practice not to include the extension unless really necessary.) – cfr Nov 11 '15 at 00:28

2 Answers2

2

Sorry, but the MWE package doesn't provide any images with transparent backgrounds. BTW, you probably should change the background color to white.

\documentclass{beamer}
\usepackage{xcolor}
\usepackage{graphicx}

\newcommand{\fillgraphics}[2][]% same as \includegraphics
{\bgroup
  \sbox0{\includegraphics[#1]{#2}}%
  \hbox{\color{red}\rlap{\rule{\wd0}{\ht0}}\box0}
 \egroup}

\begin{document}
\begin{frame}
\fillgraphics[width=.9\textwidth]{images/cloud.png}
\end{frame}
\end{document}

cloud with red sky

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • I deleted my answer because it was very similar to yours, but yours is better (simpler, more efficient). +1 – Steven B. Segletes Nov 11 '15 at 05:45
  • I can reproduce this using your code but when I replace standalone with beamer then surround the fillgraphics command by \begin{frame}{} and \end{frame}, the colored layer is not aligned with the image. It is above it on the page then followed by the image. – Steven C. Howell Nov 12 '15 at 01:09
  • Weird, but correctable. Beamer is a world unto itself. – John Kormylo Nov 12 '15 at 04:13
2

Here's the version for TikZ fans like myself:

Code

\documentclass{beamer}
\usecolortheme{beetle}
\usepackage{tikz}

\begin{document}

\begin{frame}
\begin{tikzpicture}
    \node[fill=white] {\includegraphics[scale=1]{cclogo}};
\end{tikzpicture}

\includegraphics[scale=1]{cclogo}
\end{frame}

\end{document}

Output

enter image description here

Tom Bombadil
  • 40,123