15.6.11

Background images

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{}{
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{}{}{}, 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!

No hay comentarios:

Publicar un comentario