I want to put a background image on a file which uses the scrartcl class. The target pdf output size is A4 which is exactly the size of the background image (210mm x 297mm). The image should therefore cover the whole page.

This is what I've tried so far:

    Hello World!

Unfortunately I get an error message

Package atveryend Info: Empty hook `BeforeClearDocument' on input line 11. <./bg1.png, id=4, 597.432pt x 845.0772pt> File: ./bg1.png Graphic file (type png)

Package pdftex.def Info: ./bg1.png used on input line 11. (pdftex.def) Requested size: 597.50662pt x 845.0455pt.

! Undefined control sequence. \xwm@makedraftbox ...@begingroup \ttfamily \color {red}\Large (draft mode)\c... l.11 \end{document}

and the result does not look very promising


Do you have any idea what the problem might be?

This is the test-background I've used:



1 Answer 1


I would recommend the background package for this. Admittedly, this is mostly because I know it mostly works. (However, it turns out, there is also a good reason to use something other than xwatermark if using a KOMA class. See below.)

Solution with background package

For example:

    Hello World!

background background image

Diagnosis and solution with xwatermark

If you want to keep using xwatermark, things are a bit more complicated. The first point is that the package seems to require, but not load, the color package. At least, I got errors without it so I added


According to the manual (page 8):

For graphics/picture watermarks, you need the picfile (the graphics filename, with its full path but without its extension), picfileext (the picture filename extension without the dot), picbb (the picture bounding box), and picscale (the picture scale).

So I figured that I would see what happened if I set the watermark using just those keys. Not having much idea what the boundinb box should be, I took the default value xwatermark uses and made it explicit.

\newwatermark[allpages,picscale=1,picfile=./bg1,picfileext=png,picbb=0 0 100 100]{}

This starts to give a sense of where the problem might lie:

output with default bb and minimal settings

Exactly the same result is obtained, unsurprisingly, if we use


and let the package use the default bounding box.

So what is happening is that the package uses a bounding box which captures only a small part of the picture. Although picscale=1 tells it not to scale the image, the later options setting the image's width and height override this and xwatermark scales the image accordingly. That is, it magnifies the small part of the picture inside the bounding box 0 0 100 100 so that it fills the requested area.

So, to get the desired output, it is necessary to determine the correct bounding box.

The output from running pdflatex tells us that the image dimensions are 597.432pt x 845.0772pt. Hence, a good bet would seem to be

\newwatermark[allpages,picscale=1,picfile=./bg1,picfileext=png,picbb=0 0 597.432pt 845.0772pt]{}

and, indeed, this gives the desired result:

output with corrected bounding box

Complete code:

\newwatermark[allpages,picscale=1,picfile=./bg1,picfileext=png,picbb=0 0 597.432pt 845.0772pt]{}
    Hello World!\newpage

Note that use of xwatermark will break some functionality when using a KOMA class because the package loads fancyhdr. KOMA issues a warning about this on the console.

Unless you need xwatermark specifically, therefore, it would probably be better to use the background solution or similar. Not only is that strategy simpler, but it should also be fully compatible with KOMA as far as I know.

You must log in to answer this question.

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