# Watermark with LstListing

I'm trying to add a draftwatermark to my document, but I'm having some problems with lstlisting.

Whenever I've used lstlisting (for C++ code), the background of the code section is white and overwrites (draws?) the Draft in the background.

I've seen you can change the background colour of the lstlisting, but I haven't been able to find a way to set it to transparent.

What would be the best way of dealing with this?

-

• Do not use option backgroundcolor for the listings, if you do not want the background color. backgroundcolor={} clears a previously set background color.

• If you are using pdfTeX in PDF mode, then package transparent can be used for transparency.

The following example uses page color as simplified draft watermark:

\documentclass{article}
\usepackage{listings}
\usepackage{color}
\usepackage{transparent}
\pagecolor{yellow}
\begin{document}
\section{Hello World}
\begin{lstlisting}[backgroundcolor=\transparent{.5}\color{red}]
Hello World
\end{lstlisting}
\end{document}


Result: The red code background becomes orange:

-
I would aslo advise to add the line \pdfpageattr {/Group << /S /Transparency /I true /CS /DeviceRGB>>} before your \documentclass{} as otherwise adobe reader will not display pages with transparency properly (very ragged fonts with no anti-aliasing) –  ArTourter Jan 17 '13 at 15:28