Featured Post

We've moved to tex.my!

It’s been great writing on Blogger.com, but we’ve decided to move to a new platform, thanks to some valuable help from a great, great friend...

Sunday, October 18, 2009

Background images

I'm sure every LaTeX user tried this code at least once to add a "background image" on a page:


But the included graphics, even though it looks the right size, would refuse to budge beyond the page margins, leaving a white border all round it. And you'd probably have problem placing any text at all on the graphics, thus defeating the purpose of a "background" image.

The wallpaper package offers an easy way to add background images or wallpapers in LaTeX, including tiling. The following commands are available:

  • \CenterWallPaper{<scaling>}{<filename>} where <scaling> is a value between 0 and 1, for specifying the fraction of paper width or height. The aspect ratio of the graphics will not be changed, i.e. you won't get a "stretched" wallpaper as you would with your desktop wallpapers.
  • \ULCornerWallPaper{<scaling>}{<filename>}
  • \LLCornerWallPaper{<scaling>}{<filename>}
  • \URCornerWallPaper{<scaling>}{<filename>}
  • \LRCornerWallPaper{<scaling>}{<filename>}
The above four commands take the same arguments as \CenterWallPaper, but puts the image at the Upper Left, Lower Left, Upper Right and Lower Right corners of the page respectively.

For tiling wallpapers, there are:
  • \TileWallPaper{<width>}{<height>}{<filename>}, where you can specify (in pt, cm, in...) the width and height of the included image.
  • \TileSquareWallPaper{<number>}{<filename>}, where the included image would be re-shaped as a square, and <number> is the number of "image tiles" that will fill up the width of the paper.
Note that all the commands above will apply the background images on every page after the command is issued. To clear the wallpaper, use \ClearWallPaper.

Also, for each command \XXXWallPaper command above, there is a \ThisXXXWallPaper command that takes the same arguments but would apply the background image on only the current page.

You can now run wild with your imagination to design letterheads, chapter headings, covers, etc. Have fun!


  1. this will work for beamer as well?
    no plan to try yet since doing well with plain white as for now :D

  2. No, najmi, it won't, at least not right out of the box. That's 'cos the "wallpapers" are placed on the page by the eso-pic package first, but then beamer will lay the default white background canvas _over_ it.

    In fact, you can set background images in beamer without using the wallpaper package. Use something like the following to include a background image:


    If you really, really want to use the wallpaper package with beamer, then you need to add this line to make the default white background canvas transparent instead:

    \setbeamercolor{background canvas}{bg=}

  3. Great package! My documents get a new fresh design - thanks a million!

  4. Is there a way of placing a single wallpaper image somewhere other than UL, UR, LL, LR corners or the center of the page?

    1. You can use \CenterWallPaper, then \wpXoffset and \wpYoffset to tweak the position of the image on the page (see the wallpaper package documentation for more details).

      Alternatively, you may want to take a look at the textpos package.

    2. Could you provide an example of how this syntax would work? I haven't found an example in the documentation.

      Thanks in advance!

    3. The offsets are lengths that you can manipulate with \setlength and \addtolength.You could do something like this:


      where a positive X offset shifts the image to the right, and a positive Y offset shifts it up.

      If you're using sciposter.cls, The documentation has this to say:

      "In a beta version of wallpaper.sty it appeared that the manipulation of \hoffset by sciposter.cls caused problems, which could be solved by setting \wpXoffset to -\hoffset (which is now the default)."

    4. Ah... Thanks! : )

      I'd tried something similar using \URCornerWallPaper, and couldn't figure out why it wasn't working!

    5. If your image is relatively small, doesn't overlap other page elements (including the main text) and supposed to go near one of the page corners, perhaps you could try placing it in the footer? :-)

    6. Won't work for what I want (I'm trying to position graphics along the edges but so that fit neatly into whitespace left open by the text flow), but thank for the suggestion.

      \wpXoffset seems to work okay, except that it's not obvious how to add more than one image this way.

    7. Turns out that textpos was the best for my purposes. Thanks for the tip!