11

Is there any way I can execute a command (\ifthenelse actually) at the start of every page?

I tried \AtBeginShipout (atbegshi) but that seem to get executed when the page is about to be rendered (shipped out). I want something different, as soon as the page is about to start.

12
  • What's the ultimate effect you're trying to achieve here? There are various mechanisms depending on what you have in mind: eg, something like adding a "DRAFT" watermark, or something like adding a header/footer, or something like putting "Theorem 2 (contd.)" if a previous section is overflowing onto this page.
    – Lev Bishop
    Nov 15, 2013 at 17:30
  • @LevBishop Actually, I want to test if the page number has a certain value, if the answer is yes, I want to execute a predefined command at that point. And this command is not included the cases (adding .... onto this page) you enumerated.
    – Masroor
    Nov 15, 2013 at 17:37
  • What kind of command would you execute? Note that you cannot act on what TeX has already typeset; when it breaks a page, it usually has already typeset a complete paragraph, so this cannot be modified any more.
    – egreg
    Nov 15, 2013 at 17:41
  • 1
    @MMA You can't change the geometry mid page. And TeX is typicall mid page when it decides to make a page break.
    – egreg
    Nov 15, 2013 at 17:50
  • 1
    @MMA you'd need something like this but determining at what line the page breaks is hard in general tex.stackexchange.com/a/142039/1090 Nov 15, 2013 at 19:44

1 Answer 1

7

You'll need the package bophook to add commands at the beginning of each page:

Using the \AtBeginPage hook, you can add material in the background of a page. Think of it as a construct that does: For every page, create a picture environment with its origin at the top left corner of the paper (resp., output device). So for example, you can put an image that is three centimeters from the left border and five from the top border by saying

\AtBeginPage{%
   \setlength{\unitlength}{1cm}
   \put(3, -5){\makebox(0,0)[tl]{\includegraphics{image}}}
}
0

You must log in to answer this question.

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