When I include code snippets in my documents, my lazier readers, i.e. students :), are often tempted to just copy and paste those snippets instead of typing them themselves. However, there are risks associated with that practice.

                         enter image description here

Copying and pasting of listings is the subject of numerous questions on the site; at the time of writing this question, the search copy paste [listings] is:question returns at least ten questions relevant to that problem. The answers to those questions show that the problem remains, by and large, unsolved.

Therefore, instead of letting my readers run the risk of saving an imperfect copy of one of my listings to their "clipboard", I'd like to preclude them from copying anything from my listings. Niet. Nada. Nichts. Rien du tout! Because I still want to make the source code available to them, though, I plan to embed it in the PDF instead.

How can I preclude my readers from copying my listings?


  1. My question is related to Mangling listings source code. However, I cannot afford to export the listings as raster images only to import them back as graphics is not an option, because I want to keep the listings in vectorised format.

  2. Also, I do not want to encrypt the whole PDF as in Is it possible to produce a PDF with un-copyable text?. I simply want to forbid copying of my listings.

  3. I don't care that OCR can be used to recover my listings. I suspect most of my users wouldn't know how to use OCR or wouldn't do it just to avoid having to type a listing themselves.


1 Answer 1


Add a watermark!

You prevent an easy copy by adding a background picture with a watermark (»Don't copy!«) to every listing. A solution has been suggested here: https://tex.stackexchange.com/a/63590/4736 . I did not test that, but I presume you cannot copy only the listing, without the letters of the watermark.

  • Sorry for getting back to you so late. Thanks for your suggestion, but I don't the approach would work for listings spanning multiple pages.
    – jub0bs
    Mar 31, 2014 at 12:59

You must log in to answer this question.

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