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?

3
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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.