3

I am looking to put an image on the first page of each chapter, only, behind the chapter title. I assume that I should be using the package background, since the image will be behind text, but I cannot get it to play nicely in the chapterstyle code - it is currently placing the image on the first page of the file, no connection to the chapter page.

(Preamble) Code I am using:

\documentclass{memoir}
\usepackage{pgfornament}
\usepackage{graphicx}
\usepackagepages=some]{background}
\backgroundsetup{
scale=0.75,
position={6,-6},
angle=0,
contents={%
  \includegraphics{image}
  }%
}


\makechapterstyle{custom}
{\BgThispage
\renewcommand\chapternamenum{}
\renewcommand\printchaptername{}
\renewcommand\chaptitlefont{\fontsize{18}{18}\scshape\centering}
 }
\chapterstyle{custom}

Is it possible to use background at all in \makechapterstyle?

1
  • Thanks. You are correct, this is '\documentclass{memoir}'
    – Kitty
    Commented Mar 1, 2018 at 23:09

1 Answer 1

3

I could have chosen any of the component macros. None of them have arguments, but I figured \afterchapternum was probably the simplest.

I'll let you tweak the positioning.

\documentclass{memoir}
\usepackage[pages=some]{background}
\backgroundsetup{
scale=0.75,
position={6,-6},
angle=0,
contents={%
  \includegraphics{example-image}
  }%
}

\makechapterstyle{custom}
{\let\temp=\afterchapternum
\renewcommand\afterchapternum{\temp\BgThispage}}
\chapterstyle{custom}

\usepackage{lipsum}

\begin{document}
\chapter{First}
\lipsum[1-8]

\end{document}

For book class, replace the memoir specific code with

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@makechapterhead}{\thechapter}{\thechapter\BgThispage}{}{Failed!}
\makeatother
4
  • How to add this thing to the book class?
    – Qaher
    Commented Oct 9, 2020 at 20:28
  • Not as such. What you can do is put the image in a global savebox before \chapter and modify \@makechapterhead to add it behind the title. Don't even need the background package. Commented Oct 10, 2020 at 1:07
  • Can you please provide an example as an update for your answer? I think the book class is more popular for LaTeX.
    – Qaher
    Commented Oct 10, 2020 at 3:48
  • Actually, one could simplify the original solution using \apptocmd from etoolbox. Commented Oct 10, 2020 at 17:36

You must log in to answer this question.

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