4

I have a 2-page document (letter) where I want to have a background image on both pages, but not the same image on both. It seems as though the wallpaper package can only work with one image. Is there a way to use two different images?

azetina
  • 28,884
Sam
  • 41
  • 2
    Have you tried the background package and and \if statement. For example: http://tex.stackexchange.com/q/131824/10898 . Also look at http://tex.stackexchange.com/a/46281/10898 – azetina Oct 19 '13 at 20:40
  • 1
    "the wallpaper package can only work with one image" - Are you sure? You can use \ThisCenterWallPaper{#1}{#2} to set wallpaper on the next page only. – masu Oct 20 '13 at 03:01
  • @Shannon -- This solution may be a way to do http://tex.stackexchange.com/a/134795/34618 – Jesse Oct 20 '13 at 04:49

2 Answers2

1

This TeX.SX answer is good background reading: it shows us how to create a background for a single page using TikZ, though it also requires you to know exactly where the page is going to end. Changing it a little bit produces a macro that sets the background of whatever page it's on:

\newcommand*{\PageBackground}[1]{
    \tikz[remember picture,overlay] \node[opacity=0.3,inner sep=0pt] at (current
    page.center){\includegraphics[width=\paperwidth,height=\paperheight]{#1}};
}

Since you know that your letter is only two pages, you can call \Pagebackground{image_name} at the beginning of your document (which is on the first page) and at the end (which is on the second). If you want to expand this solution to multiple pages, you'll want to call \PageBackground once per page, within a document element that is on the page.

Here's an example document, where light1.png and light2.png can be replaced by your preferred backgrounds:

\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\newcommand*{\PageBackground}[1]{
    \tikz[remember picture,overlay] \node[opacity=0.3,inner sep=0pt] at (current
    page.center){\includegraphics[width=\paperwidth,height=\paperheight]{#1}};
}

\begin{document}
\PageBackground{light1}
\lipsum[1-7]
\PageBackground{light2}
\end{document}

enter image description here

Arun Debray
  • 7,126
  • 2
  • 30
  • 54
1

As [masu mentioned]{Using two different wallpapers in the same document}, wallpaper certainly supports different backgrounds in a single document:

felines of all stripes

\documentclass{article}
\usepackage{wallpaper,graphicx,kantlipsum}
\begin{document}
  \ThisCenterWallPaper{1}{tiger}
  \kant[1-6]
  \ThisCenterWallPaper{1}{cath-gadael-chartref}
\end{document}

If you want something like conditional inclusion, then something like the background package is more straightforward and flexible. But for a simple, two-page document, wallpaper is a lighter, simpler choice.

cfr
  • 198,882