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?
Asked
Active
Viewed 360 times
3
2 Answers
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}
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
standalonewithbeamerthen surround thefillgraphicscommand 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 -
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
Tom Bombadil
- 40,123
-
-
-
@stvn66: The white background is a little bigger than the image. To influence this you can use the
inner sepkey.\node[fill=white, inner sep=0mm]will remove it, and you can also use it to add a border of a defined length. – Tom Bombadil Nov 12 '15 at 07:13


\begin{tikzpicture}\node[inner sep=0, fill=white] {\includegraphics{pic.eps}};\end{tikzpicture}– Tom Bombadil Nov 10 '15 at 19:10