0

I add a background image to every page and want to add a different one based on the name of the current chapter. It would also be good to know how whether the preface and title pages before the chapters start need their own treatment.

I unsuccessfully tried:

\documentclass{book}%
\usepackage[T1]{fontenc}%
\usepackage{graphicx}%

\AddToHook{shipout/background}{\put(0pt, -\paperheight) {\includegraphics[width =\paperwidth, height =\paperheight]{\chaptermark}}}% % \begin{document}% \chapter{example-image} x \end{document}

Christian
  • 341

1 Answers1

2

Well you can extend \chaptermark to store the name. If you need a different name for some chapters, simply redefine it after the chapter.

\documentclass{book}%
\usepackage[T1]{fontenc}%
\usepackage{graphicx}%

\AddToHook{shipout/background}{\put(0pt, -\paperheight) {\includegraphics[width =\paperwidth, height =\paperheight]{\mychaptername}}}% % \newcommand\mychaptername{}

\NewCommandCopy\orichaptermark\chaptermark \renewcommand\chaptermark[1]{\orichaptermark{#1}\def\mychaptername{#1}} \begin{document}% \chapter{example-image} x \end{document}

Ulrike Fischer
  • 327,261