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?

3
  • 3
    Probably with TikZ? Something like \begin{tikzpicture}\node[inner sep=0, fill=white] {\includegraphics{pic.eps}};\end{tikzpicture} Nov 10, 2015 at 19:10
  • Can you make one of the images available for download and add a link here? Nov 10, 2015 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, 2015 at 0:28

2 Answers 2

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

3
  • I used this EPS image Nov 11, 2015 at 7:51
  • I was able to use this to add the white layer. Nov 12, 2015 at 1:10
  • @stvn66: The white background is a little bigger than the image. To influence this you can use the inner sep key. \node[fill=white, inner sep=0mm] will remove it, and you can also use it to add a border of a defined length. Nov 12, 2015 at 7:13
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

3
  • I deleted my answer because it was very similar to yours, but yours is better (simpler, more efficient). +1 Nov 11, 2015 at 5: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. Nov 12, 2015 at 1:09
  • Weird, but correctable. Beamer is a world unto itself. Nov 12, 2015 at 4:13

Not the answer you're looking for? Browse other questions tagged .