TransWikia.com

Use eso-pic to set pictures on most pages

TeX - LaTeX Asked on April 11, 2021

I understand that the eso-pic package can be used to add pictures to every page, or to a single page.

But what about adding pictures to most pages?

Ideal behaviour: eso-pic adds pictures to every page, but I can "switch off" the picture for some pages with a thispagestyle{empty} (or something else similarly convenient).


MWE

documentclass{report}

pagenumbering{gobble}
usepackage{eso-pic,color}

% Add colour footer
AddToShipoutPictureBG{
  AtPageLowerLeft{%
    color{red}%
    rule{pdfpagewidth}{2cm}%
  }
}

begin{document}

This is my nice title page.

I don't want a colour footer here.

clearpage

I understand that eso-pic makes it easy to add pictures to every page, or a
single page. But what about adding pictures to emph{most} pages?

clearpage

Doing the good good science

clearpage

For whatever reason (full page figure, table, whatever), I don't want a footer
here either.

end{document}

Thoughts

I understand that the internal ESO@HookIBG stores all the picture commands to be used, and that I can clear its contents with ClearShipoutPictureBG. I figured I could remove the pictures for a single page as:

  1. capture ESO@HookIBG contents (let?)
  2. call ClearShipoutPictureBG
  3. page content
  4. restore ESO@HookIBG from the capture of 1.

But I’m unsure how to actually implement this (and how I could make it’s usage more convenient by hooking it into a thispagestyle{empty} or something similar.)

One Answer

With a new (current) latex you could try something like this

documentclass{report}

pagenumbering{gobble}
usepackage{eso-pic}
usepackage{color}


% Add colour footer
newififmyfooter
globalmyfootertrue
AddToShipoutPictureBG{
  AtPageLowerLeft{%
   ifmyfooter
    color{red}%
    rule{pdfpagewidth}{2cm}%
   fi 
   globalmyfootertrue
  }
}

DeclareHookRule {shipout/background}{mylabel}{before}{eso-pic}
begin{document}

This is my nice title page.

I don't want a colour footer here.

clearpage
AddToHookNext{shipout/background}[mylabel]{globalmyfooterfalse}

I understand that eso-pic makes it easy to add pictures to every page, or a
single page. But what about adding pictures to emph{most} pages?

clearpage

Doing the good good science

clearpage

For whatever reason (full page figure, table, whatever), I don't want a footer
here either.
AddToHookNext{shipout/background}[mylabel]{globalmyfooterfalse}

end{document}

Correct answer by Ulrike Fischer on April 11, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP