I’m sure every LaTeX user tried this code at least once to add a “background image” on a page:
\includegraphics[width=\pagewidth,height=\textwidth]{wallpaper_filename}
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{}{} where 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{}{}
- \LLCornerWallPaper{}{}
- \URCornerWallPaper{}{}
- \LRCornerWallPaper{}{}
For tiling wallpapers, there are:
- \TileWallPaper{}{}{}, where you can specify (in pt, cm, in…) the width and height of the included image.
- \TileSquareWallPaper{}{}, where the included image would be re-shaped as a square, and 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!
this will work for beamer as well?
no plan to try yet since doing well with plain white as for now 😀
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:
setbeamertemplate{background}{includegraphics[width=paperwidth,height=paperheight]{}}
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=}
Great package! My documents get a new fresh design – thanks a million!
Is there a way of placing a single wallpaper image somewhere other than UL, UR, LL, LR corners or the center of the page?
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.
Could you provide an example of how this syntax would work? I haven't found an example in the documentation.
Thanks in advance!
The offsets are lengths that you can manipulate with setlength and addtolength.You could do something like this:
CenterWallPaper{.3}{bg-pattern}
setlength{wpXoffset}{3cm}
setlength{wpYoffset}{3cm}
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).”
Ah… Thanks! : )
I'd tried something similar using URCornerWallPaper, and couldn't figure out why it wasn't working!
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? 🙂
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.
Turns out that textpos was the best for my purposes. Thanks for the tip!