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?

1 Answer 1

  • 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:

\section{Hello World}
Hello World

Result: The red code background becomes orange:


  • 1
    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, 2013 at 15:28

You must log in to answer this question.

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