I am currently designing an application template for myself and maybe some colleagues and I have a little trouble with \backgroundsetup.

The structure of the document I am aiming for shall look as follows


          some text

          some text

       and so on


In each environment, I would like to set the background based on a pdf-file. However, \backgroundsetup does not work if I call it inside either \newenvironment or \NewEnviron.

Can anyone help me to fix that?

Here a minimum example




\newcommand*{\setbackground}[1]{\backgroundsetup{contents={\includegraphics[height=303mm, width=216mm]{#1}}}}



      This is a test        


bg is the background image and should work with any DinA4 pdf document.

Thanks a lot advance!

  • 2
    Most likely the change from \backgroundsetup gets lost inside the group formed by the environment -- it is unknown then when the page is shipped out
    – user31729
    Dec 14 '17 at 11:40
  • 1
    Is \NewEnviron{coverletter}{\setbackground{ente}\BODY}[\clearpage] acceptable for you?
    – user31729
    Dec 14 '17 at 11:45

After some tinkering, I finally ended up with the following code. Just in case someone wants to do something similar in the future.

\newcommand{\topbar}{\draw[fill=dark, draw=none] (0,0) rectangle (216mm,-83mm);}
\newcommand{\narrowtopbar}{\draw[fill=dark, draw=none] (0,0) rectangle (216mm,-23mm);}
\newcommand{\sidepanel}{\draw[fill=light, draw=none] (13mm,-23mm) rectangle (83mm,-280mm);}
\newcommand{\footer}{\draw[fill=light, draw=none] (0mm,-303mm) rectangle (216mm,-290mm);%
    \filldraw [fill=dark, draw=none] (184mm,-292.5mm)  coordinate (GeneralStart) -- ++(0,0) -- ++(+3.2,0) -- ++(0,-1.05) -- ++(-4.0,0) -- cycle;}

        \begin{tikzpicture}[remember picture,overlay]
        \node[xshift=-108mm, yshift=151.5mm] at (current page.center)
            \begin{tikzpicture}[remember picture, overlay]%

I can then call \setbg{\topbar\sidepanel\footer}\clearpage to set my page-background. Note, that the \AtBeginPage-command is provided by the bophook-package.

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.