# Techniques for embedding images with transparent backgrounds in LaTeX

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.

-

## migrated from stackoverflow.comMay 20 '11 at 12:19

This question came from our site for professional and enthusiast programmers.

For posters in general I would recommend beamerposter. –  Martin Scharrer May 20 '11 at 14:04
Welcome to TeX.sx! Your question was migrated here from another stackexchange site. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. –  N.N. Aug 13 '11 at 13:32

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.

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}


-
I find it a little peculiar that you use a 64-bit (16 bit/channel) PNG. In fact that 64-bit PNG crashes my LaTeX (BaKoMa TeX). Can you do the same thing using a regular 32-bit png image (which I verified as having a transparent background) ? Here are my results with a 32-bit png (it doesn't work) –  bobobobo Jul 14 '12 at 13:54
@bobobobo: I wasn't aware about the 64-bit. I just looked around for any transparent PNG. I tried it with you PNG and it works fine (TeX Live 2012): i.stack.imgur.com/vMkIq.png, i.stack.imgur.com/89Gdm.png –  Martin Scharrer Jul 14 '12 at 15:34

it is simple for an eps image:

\documentclass{minimal}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage{pst-node,graphicx}
\SpecialCoor
\begin{document}
\noindent\pnode(0.5\textwidth,-0.5\textheight){Center}
\blindtext[6]
\rput(Center){\special{ps: 0.4 .setopacityalpha}\includegraphics[width=\textwidth]{tiger.eps}}

\end{document}


-

pdflatex with graphicx-package and/or PGF is able to include PNG or certainly PDF, both can have transparent backgrounds.

If you have to use latex with dvi2ps or something like that try it wit an EPS image.

-
I am having a lot of trouble including PDFs with transparency (no problems with PNGs). I can't find much about the topic and you seem like you have it working. Do you have to do anything special to get transparent PDFs to get included properly? –  vlsd May 10 '12 at 1:27
@VladSeghete: Until now I only used PDFs with transparent (not semi transparent something between opaque and transparent) parts without any problems, but I know that semi transparencies can cause problems … Sorry that I can’t help better. –  Tobi May 10 '12 at 8:32