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:

\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 '13 at 15:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.