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
    Commented Oct 29, 2020 at 19:44

1 Answer 1

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. Commented Oct 30, 2020 at 19:12

You must log in to answer this question.

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