2

I want to put something (usually a specially positioned graphic) on most pages, but being able to turn this on and off, independently of the header/footer. I have a feeling that there is a basic LaTeX macro, or a package, that lets me do this but for the life of me I can't remember it. Here is a sort of MWE of what I am trying to do.

\documentclass{book}
\usepackage{lipsum}
\usepackage{onoffpages}  %% how do I get/define this?

\begin{document}

% seems like picture can now cope with actual values
\oneverypage{  %% put this on every page from now on
\begin{picture}(0,0)
\put(0,-\textheight){0, -textheight}
\put(\textwidth,-\textheight){textwidth, -textheight}
\put(0,0){0, 0}
\put(\textwidth,0){textwidth, 0}
\end{picture}
}
\lipsum[1-10]

\stopeverypage %% don't put anything extra on pages from now on (kills \oneverypage)

\lipsum[1-10]

\end{document}
1
  • 2
    Maybe the package eso-pic?
    – campa
    Oct 29 '20 at 19:44
5

You can use the shipout hooks. But you will have to adjust the values to your needs - the starting point is the left upper corner (so I had to use -10pt to get the text on the page).

\documentclass{book}
\usepackage{lipsum}


\begin{document}


\AddToHook{shipout/background}[mypic]
 {
  \put(0,-\textheight){0, -textheight}
  \put(\textwidth,-\textheight){textwidth, -textheight}
  \put(0,-10pt){0, 0}
  \put(\textwidth,-10pt){textwidth, 0}
}
\lipsum[1-10]

\RemoveFromHook{shipout/background}[mypic]

\lipsum[1-10]

\end{document}
  
1
  • This was just what I wanted. As you said I have to choose the length values to suit my application(s). Thank you. Oct 30 '20 at 19:12

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.