[Tex/LaTex] Set background image without tikz

backgroundsgraphics

I'm creating a 100-pages-long procedurally generated document in which every page has a different background. The background picture is not procedurally generated, but it's loaded from a directory.

Up to now I used tikz for that, but as explained here I encountered some issue with the fact that the document needs several runs to get everything right. Sadly recently the document became so big that the background picture won't ever come out in the right position.

So, I'm looking for a way to set a background image without using tikz, since I believe that the issue is entirely caused by it: I have an other picture in the page, loaded with the usual \includegraphics command, and it always comes out in the right position.

Best Answer

See if this can fulfill your needs, note that there are other options, but most of them rely on TikZ internally.

\documentclass{article}
\usepackage{eso-pic,graphicx}
\usepackage[top=2cm, bottom=2cm, outer=0cm, inner=0cm]{geometry}
\newcommand{\background}[1]{%
\AddToShipoutPictureBG*{\includegraphics[width=\paperwidth,height=\paperheight]{#1}}
}
\begin{document}
Text here normally ...
\background{example-image-A}
\clearpage

text on next page ...
\background{example-image-B}
\clearpage

and text on third page ...
\background{example-image-C}
\end{document}

enter image description here

Related Question