1

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 Mar 1 '18 at 23:09
2

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 Oct 9 '20 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. – John Kormylo Oct 10 '20 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 Oct 10 '20 at 3:48
  • Actually, one could simplify the original solution using \apptocmd from etoolbox. – John Kormylo Oct 10 '20 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.