I'm making a document with 4 background images: for each page, I have a different one. So pages 1,5,9,13 have the same image, 2,6,10,14, another, and so on.
I'm currently doing this manually, but not only does this pollutes the code, but also is very tiring and boring. I would like to know if it's possible to automatize it.
Also, for each background, I use a different font color. And I'm also doing this manually. This is even worse, because I have to set precisely where I want it to start.
My code:
Code: Select all
\documentclass[12pt,a4paper]{article}
\usepackage{xltxtra}
\usepackage{xunicode}
\usepackage[brazil]{babel}
\usepackage[vmargin={5.5cm, 7cm},hmargin={3.5cm, 4.6cm}]{geometry}
\usepackage{graphicx,color}
\usepackage{eso-pic}
%Define background images
\newcommand\BackgroundBlue{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
\includegraphics[width=\paperwidth,height=\paperheight,
keepaspectratio]{Blue.png}%
\vfill
}}}
\newcommand\BackgroundRed{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
\includegraphics[width=\paperwidth,height=\paperheight,
keepaspectratio]{Red.png}%
\vfill
}}}
\newcommand\BackgroundGreen{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
\includegraphics[width=\paperwidth,height=\paperheight,
keepaspectratio]{Green.png}%
\vfill
}}}
\newcommand\BackgroundViolet{
\put(0,0){
\parbox[b][\paperheight]{\paperwidth}{%
\vfill
\centering
\includegraphics[width=\paperwidth,height=\paperheight,
keepaspectratio]{Violet.png}%
\vfill
%Define colors
[code]\definecolor{Blue}{rgb}{0.19,0.52,0.61}
\definecolor{Red}{rgb}{0.58,0.21,0.20}
\definecolor{Green}{rgb}{0.46,0.57,0.24}
\definecolor{Violet}{rgb}{0.37,0.29,0.48}
}}}
\begin{document}
\AddToShipoutPicture*{\BackgroundBlue}
\color{Blue}
Page 1
\newpage
\AddToShipoutPicture*{\BackgroundRed}
\color{Red}
Page 2
\newpage
\AddToShipoutPicture*{\BackgroundGreen}
\color{Green}
Page 3
\newpage
\AddToShipoutPicture*{\BackgroundViolet}
\color{Violet}
Page 4
\newpage
\AddToShipoutPicture*{\BackgroundBlue}
\color{Blue}
Page 5 - Same font color and background of Page 1
\end{document}