[Tex/LaTex] How to get \AddToShipoutPicture* to place image at top of page

graphicswallpaper

I'd have a PDF image that I'd like to use as a background as follows:

  • Scaled to width of the page
  • Positioned at the top of the page such as it is flush with both upper corners
  • The rest of the document should lay out as normal

The image does not cover the entire page. It's more like a banner.

I came up with the following:

\documentclass{article}
\usepackage{eso-pic}
\usepackage{mwe}

\begin{document}
  \AddToShipoutPicture*{%
      \parbox[t][\paperheight][t]{\paperwidth}{%
           \includegraphics[width=\paperwidth]{example-image}
      }
  }
  The quick brown fox jumped over the lazy dogs.
\end{document}

This almost works, except that the image is at the bottom of the page. I also tried wrapped \parbox at with \put(0,0){...} but that didn't help. If I replace \includegraphics with text, the text is rendered at the very bottom left of the page.

How do I get the image to appear flush with the top left corner instead?

Best Answer

Use eso-pic's internal positioning mechanisms. In this case, \AtPageUpperLeft:

enter image description here

\documentclass{article}

\usepackage{eso-pic,graphicx}

\begin{document}

\AddToShipoutPictureBG*{%
  \AtPageUpperLeft{%
    \raisebox{-\height}{%
      \includegraphics[width=\paperwidth]{example-image}%
    }%
  }
}
The quick brown fox jumped over the lazy dog.

\end{document}

Since the image would sit on the baseline (in general), \AtPageUpperLeft would actually place the image so it sits "above" the page. However, \raisebox{-\height} brings it down into view on the actual page.