1

This question is similar to the unanswered How to put something on a page without disturbing the main vertical list? but (very slightly) more tightly defined.

I want to put a picture in the background of a page using eso-pic and \AddToShipoutPictureBG*.

Now, by default this page won't be output unless there is actually something on it.

I want it to show up when the page is empty and when the page contains content, but without knowing beforehand which case is wanted.

I can't just insert \null because this messes with the main vertical list and things like \section will then be at the wrong place at the top of the page.

Is there anything I can do or any work around?

MWE

\documentclass{article}
\usepackage{eso-pic}
\usepackage{graphicx}
\begin{document}
\AddToShipoutPictureBG*{%
  \AtPageCenter{%
    \makebox(0,0){\includegraphics{example-image.pdf}}}}
% <- insert something that doesn't mess with vertical spacing but causes the
%    page to be output.
% <- possible further content (e.g., \section{...}) or possibly no content.
\end{document}
  • I will delete my above comments. Since your MWE did not have an \section or other code, I did not test it that way. – user139954 Apr 18 '18 at 14:52
  • @RobtAll, no worries. The MWE is for the case with no content, but does include \section in the comments. (And to be fair, I mentioned \null in the question.) – David Purton Apr 18 '18 at 14:57
  • did you try \ifvmode\leavevmode\fi – touhami Apr 18 '18 at 19:39
  • @touhami, this doesn't work. Extra vertical space is still inserted before \section. – David Purton Apr 19 '18 at 3:42
  • you can wrap it in \AtEndDocument? – touhami Apr 20 '18 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.