# visual problem with eso-pic

I'm using this code to produce a pdf with three pages:

the first with ad image (and no text inside), the second with normal text, the third like the first.

\documentclass[oneside,a4paper,12pt]{book}

\usepackage{layaureo}
\linespread{1.5}

\usepackage{eso-pic}
\usepackage{graphicx}

\pagestyle{plain}

\begin{document}

\AddToShipoutPicture*{%
\put(0,0){\includegraphics{back}}%
}

\phantom{}

\newpage
text
\newpage

\pagenumbering{gobble}

\AddToShipoutPicture*{%
\put(0,0){\includegraphics{back}}%
}

\phantom{}

\end{document}


If I delete \phantom all pages are joined in a single page.

is there any trick or automatic command to do the same?

## 1 Answer

It seems you are simply putting a background picture on pages 1 and 3 (via \AddToShipoutPicture*). Except, there is no actual content on those pages. \phantom creates a phantom space...thereby creating content on the pages. In fact, you can completely remove \AddToShipoutPicture*{\put(0,0){\includegraphics{42}}} and have the exact same behavior (because \AddToShipoutPicture* creates a background image which is effectively an overlay and not any space on the typeset page).

You could replace \phantom with literally anything else that creates some space on the page (for example ~ or hello) and the page will break. You are getting confused thinking that \phantom is doing something special here - it is not. It is simply creating space so that the typesetting engine says "Oh, there is something - there is a page here!".

Another way to look at it is that no content plus \newpage will not create a new page. A "page" with no content and \newpage nullify each other. (La)Tex doesn't say "here's a page!" until the stuff appearing after \newpage. Similarly, when you remove \phantom on the third page, the engine sees (1) content plus (2) \newpage plus (3) no content...so no new page is actually created.

You basically have two options.

1. Continue following your current approach and realize nothing weird is happening
2. Don't put the image as a background image... instead, include it as the actual page content!

If you want to follow the second approach, here is an example:

\documentclass[oneside,a4paper,12pt]{book}

\usepackage{layaureo}
\linespread{1.5}

\usepackage{eso-pic}
\usepackage{graphicx}

\pagestyle{plain}

\begin{document}

% Old, background image approach
%\AddToShipoutPicture*{%
%\put(0,0){\includegraphics{back}}%
%}

% New approach, where image is part of the page content
\vbox to0pt{%
\makebox[\textwidth]{%
\centering%
\includegraphics{back}%
}%
}

%\phantom{}% Not needed anymore!

\newpage
text
\newpage
%\clearpage

\pagenumbering{gobble}

% Old, background image approach
%\AddToShipoutPicture*{%
%\put(0,0){\includegraphics{back}}%
%}

% New approach, where image is part of the page content
\vbox to0pt{%
\makebox[\textwidth]{%
\centering%
\includegraphics{back}%
}%
}

%\phantom{}% Not needed anymore!

\end{document}


There are a few things that I used here, which you may not need. Specifically:

• \vbox to0pt{}
• \makebox[\textwidth]{}
• \centering

Let me explain why I used them. In looking at your example, I used an image that was too large to be typeset on the the same page. LaTeX didn't like this and decided to effectively force it downwards to the next available page (i.e. creating an empty page before it).

You may not have this problem, depending on the size of your back image/PDF! So, you can simply use \includegraphics, if that gives you what you want, and delete the \vbox, \makebox, and \centering stuff.

Assuming you are using a large enough image, let me explain what each of these three lines accomplishes.

\vbox to0pt{} forces the height to basically be zero, while still being considered content on the page (and therefore typeset before the \newpage command). Basically, this is helpful if the image goes into the header/footer areas.

\makebox[\textwidth] tricks the engine into ignore the margins. Effectively, even if the image you want is wider than the normal text content, it will still be allowed on the page without an automatic new page created.

Finally, \centering simply centers the image. I think \AddToShipoutPicture*{\put(0,0){...} is effectively centering the image also, which is why I included \centering here.

I included these details because you did not show your image or how large it is. You will need to be the judge of which pieces are necessary or not, because only you know at the moment.