0

Each of my chapter titles are on a single page, with the content following on the following page. I have added a standard background image to each of those pages. What I'd like to do though, is to be able to add a different background image to each chapter. I was looking to do something like this:

\chapter{Another chapter}[background1.jpeg]
\chapter{Another chapter}[background2.jpeg]

And then be able to reference background1.jpeg and background2.jpeg in \titleformat as some sort of parameter. Is this possible?

Here's the full Latex:

\documentclass[11pt]{report}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{imakeidx}
\usepackage{lmodern}
\usepackage{titlesec}
\usepackage{eso-pic}
\usepackage{lipsum}

\titleformat{\chapter}[display]
{\vfill\filcenter}
{{%
    \filcenter\fontsize{24pt}{24pt}\usefont{T1}{phv}{m}{n}{\chaptername}
    \fontsize{24pt}{24pt}\selectfont\thechapter%
    \AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{"background.jpeg"}}
}%
}
{5pt}
{
\fontsize{48pt}{48pt}\selectfont%
}[\vfill\clearpage]
\titlespacing*{\chapter}{0pt}{0pt}{0pt}

\titleformat{name=\chapter,numberless}[display]
{\filcenter}
{{%
}%
}
{5pt}
{\Huge\usefont{T1}{phv}{b}{n}%
}

\begin{document}

\setcounter{chapter}{21}

\chapter{Chapter Title}
\section{Section one}
\lipsum[1]
\section{Section two}
\chapter{Another chapter}
\section{Section one}
\lipsum[2]
\end{document}

Environment

xelatex --version       
MiKTeX-XeTeX 4.7.1 (MiKTeX 22.1)
© 1994-2008 SIL International, © 2009-2021 Jonathan Kew, © 2010- 
2012 Hàn Thế Thành, © 2012-2013 Khaled Hosny
TeX is a trademark of the American Mathematical Society
using bzip2 version 1.0.8, 13-Jul-2019
compiled with curl version 7.77.0; using libcurl/7.79.1 
SecureTransport (LibreSSL/3.3.6) zlib/1.2.11 nghttp2/1.45.1
compiled with expat version 2.4.1; using expat_2.4.1
compiled with fontconfig version 2.13.1; using 2.13.1
compiled with freetype2 version 2.11.1; using 2.11.1
compiled with graphite2 version 1.3.14; using 1.3.14
compiled with harfbuzz version 2.7.2; using 2.7.2
compiled with icu version 69.1; using 69.1
compiled with jpeg version 9.5
compiled with liblzma version 50020052; using 50000052
compiled with libpng version 1.6.37; using 1.6.37
compiled with MiKTeX Application Framework version 4.3; using 4.3
compiled with MiKTeX Core version 4.11; using 4.11
compiled with MiKTeX Archive Extractor version 4.0; using 4.0
compiled with MiKTeX Package Manager version 4.6; using 4.6
compiled with openssl version OpenSSL 1.1.1m  14 Dec 2021; using 
OpenSSL 1.1.1m  14 Dec 2021
compiled with pplib version v2.05 less toxic i hope
using teckit version 2.4
compiled with uriparser version 0.9.6
compiled with zlib version 1.2.11; using 1.2.11

1 Answer 1

1

Try this code:

\documentclass[10pt,a4paper]{book}
\usepackage{graphicx,lipsum,emptypage}
\usepackage[placement=center]{background}
\begin{document}
    \chapter{One}
        \backgroundsetup{contents=To review,color=blue!30} %in place of 'To review' you put your image
        \newpage
        \backgroundsetup{contents=}
         % partial index of the chapter
    \chapter{Two}
        \backgroundsetup{contents=Confidential,color=blue!30} %in place of 'Confidential' you put your image
        \newpage
        \backgroundsetup{contents=}
        % partial index of the chapter
\end{document}

Output:

enter image description here

5
  • Thanks. I get this error though... ! Undefined control sequence. l.6 ^^I\backgroundsetup {contents="To review",color=blue!30} %in place of 'To...
    – Mr Goobri
    Jul 18, 2022 at 18:30
  • And also this... ! LaTeX Error: Unknown option placement=center' for package 'background'.
    – Mr Goobri
    Jul 18, 2022 at 18:32
  • 1
    How up to date is your background package? According to its documentation, the placement option was added in version 2.0.
    – Miyase
    Jul 18, 2022 at 19:14
  • Yes, I saw that too but MikTex Console says 2.1 is installed.
    – Mr Goobri
    Jul 18, 2022 at 19:56
  • 1
    I dont have errors. Perhaps you ha to reinstall your LaTeX software... Jul 19, 2022 at 5:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .