Search code examples
latexpdflatex

How to set different backgrounds for each page in LaTeX


I am trying to set different backgrounds in each page of my LaTeX document. I have tried with tikz, background and many other packages I found, but I couldn't.

I.E.

First page: \maketitle with one background

Second page: \tableofcontents with a different background

Third pages and following: Content with another background

[Edit 1]

There is something I didn't explain well. Your code helped me a lot, but I tried to modify it and had some problems.

    \documentclass[a4paper, 12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{eso-pic}
\usepackage[spanish]{babel}
\usepackage[absolute,overlay]{textpos}
\usepackage{xcolor} \definecolor{letras_portada}{RGB}{229,238,245}




\begin{document}

\AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{First_page.png}}
\begin{textblock*}{15cm}(6.35cm,23cm) 
    \huge{\textcolor{letras_portada}{\textbf{Report}}}
\end{textblock*}

\cleardoublepage

\AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{Index.png}}
\paragraph{}
\clearpage

\AddToShipoutPictureBG{\includegraphics[width=\paperwidth,height=\paperheight]{Content.png}}
\tableofcontents
\clearpage

\section{section 1}
text example 1text example 1text example 1text example 1text example 1text example 1text example 1text example 1text example 1text example
\subsection{2}
text example 1text example 1text example 1text example 1text example 1text example 1
\subsubsection{3}
text example 1text example 1text example 1text example 1text example 1text example 1



\end{document}

What I pretend as is to have a first page with my title (instead of maketitle I a text), a second page with an specific background but without text and in the third page I'd like to have the table of contents. But second page disappear.


Solution

  • One possibility is the eso-pic package. With \AddToShipoutPictureBG*{} you can change the background of the current page, with \AddToShipoutPictureBG{} of the current and all following pages.

    \documentclass{book}
    
    \usepackage{graphicx}
    \usepackage{eso-pic}
    
    \author{names}
    \title{title}
    
    \begin{document}
    
    \AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-duck}}
    \maketitle
    
    \cleardoublepage
    \AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-a}}
    \tableofcontents
    
    \clearpage
    \AddToShipoutPictureBG{\includegraphics[width=\paperwidth,height=\paperheight]{example-grid-100x100bp}}
    
    \chapter{title}
    text
    
    \end{document}
    

    To add background only pages in a one sides documentclass, you could use this quick hack:

     \documentclass[a4paper, 12pt]{article}
    
    \usepackage[utf8]{inputenc}
    \usepackage{graphicx}
    \usepackage{eso-pic}
    \usepackage[spanish]{babel}
    \usepackage[absolute,overlay]{textpos}
    \usepackage{xcolor} \definecolor{letras_portada}{RGB}{229,238,245}
    
    
    
    
    \begin{document}
    
    \AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-a}}
    \begin{textblock*}{15cm}(6.35cm,23cm) 
        \huge{\textcolor{letras_portada}{\textbf{Report}}}
    \end{textblock*}
    \mbox{}
    
    \newpage
    
    \mbox{}
    \AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-b}}
    
    
    \newpage
    
    \AddToShipoutPictureBG{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-c}}
    \tableofcontents
    \clearpage
    
    \section{section 1}
    text example 1text example 1text example 1text example 1text example 1text example 1text example 1text example 1text example 1text example
    \subsection{2}
    text example 1text example 1text example 1text example 1text example 1text example 1
    \subsubsection{3}
    text example 1text example 1text example 1text example 1text example 1text example 1
    
    \newpage
    \ClearShipoutPictureBG
    \AddToShipoutPictureBG{\includegraphics[width=\paperwidth,height=\paperheight]{example-image-b}}
    \mbox{}
    
    
    \end{document}