[Tex/LaTex] Techniques for embedding images with transparent backgrounds in LaTeX

backgroundsgraphicstransparency

I am trying to embed an image with a transparent background in my LaTeX poster. However a quick google search has taught me that it is not possible to do so. However I intend to know any clever workarounds as I believe LaTeX is frequently used for making scientific posters, which require inclusion of transparent images.

Exact problem.
I am trying to include a logo (with transparent background) in a textbox with gradient fill. Any method to accomplish this without getting a white (or any other) background is appreciated.

My current work around is the brute force technique of copying the gradient pattern in the background of the image.

Best Answer

Your Google source is wrong. The PDF version of LaTeX pdflatex supports the PNG format out of the box, including transparent PNGs. If you have your logo in another format like GIF than simply convert it to PNG first. I would not recommend to use the normal latex compiler with DVI output.

You need the standard package graphicx to include the image. Loaded xcolor would also be a good idea. Here some examples which use a transparent test PNG I got from http://entropymine.com/jason/testbed/pngtrans/rgba16.png.

\documentclass{article}

\usepackage{xcolor}
\usepackage{graphicx}

\begin{document}

\framebox{\includegraphics{rgba16.png}}
\colorbox{red}{\includegraphics{rgba16.png}}
\colorbox{white}{\includegraphics{rgba16.png}}
\colorbox{yellow}{\includegraphics{rgba16.png}}

\end{document}

The first image shown is the original transparent PNG. As you can see the other work fine with some background color.

Result 1

For advanced effects like patterns and shadings I would recommend you PGF/TikZ (i.e. the tikz package).

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{patterns}

\begin{document}
\begin{tikzpicture}
    \node [pattern=north east lines,inner sep=10pt] {\includegraphics{rgba16.png}};
\end{tikzpicture}
\begin{tikzpicture}
    \node [shade,left color=yellow,right color=blue,inner sep=10pt] {\includegraphics{rgba16.png}};
\end{tikzpicture}
\end{document}

Result 2