# inserting an image after every page

I'd like to automatically insert an image on all even pages of a document, keeping the rest of the text flow unaltered. I know I can do this using something like pdftk after compilation, but is there some way of doing it as part of the latex processing?

I know that I can do this for individual pages using the afterpage package, but I don't know how to do it automatically after every page.

Any suggestions?

• do you just want an image on every even page (no text) with the text jumping from odd to odd (relatively easy) or do you want text and images on the even page with the text flow running from odd to even under the image to odd (relatively hard) – David Carlisle Apr 13 '15 at 16:50
• The relatively easy option. (I want to insert an image of a notebook-like page after every latex page so that I can write comments on the notebook-like pages on my e-reader). Great package by the way. – JPi Apr 13 '15 at 17:06
• (my ereader reads pdf files) – JPi Apr 13 '15 at 17:12
• OK I'm going off line in a couple of minutes but will answer later if no one else has. – David Carlisle Apr 13 '15 at 17:15
• Check out the flowfram package. – John Kormylo Apr 13 '15 at 17:35

This is a solution

\documentclass{article}
\usepackage{afterpage,everypage}
\usepackage{mwe,lipsum}
\ifodd\value{page}\else\afterpage{\includegraphics{example-image-a}\vspace{\textheight}}\fi}
\afterpage{\includegraphics{example-image-a}}  %  why this is necessary?
\begin{document}
\lipsum

\lipsum

\lipsum

\lipsum

\lipsum

\end{document}


Edit: warning this is not good if you have figures, tables or footnotes

\documentclass{article}
\usepackage{afterpage,everypage}
\usepackage{mwe,lipsum}
\ifodd\value{page}\else\afterpage{\includegraphics{example-image-a}\vspace{2cm}}\fi}
\afterpage{\includegraphics{example-image-a}}  %  why this is necessary?
\begin{document}
test
\begin{figure}[t]
some test
\caption{some}
\end{figure}

\begin{figure}[t]
some test
\caption{some}
\end{figure}

\begin{figure}[t]
some test
\caption{some}
\end{figure}
\lipsum

\lipsum

\lipsum

\lipsum

\lipsum

\end{document}


footnote

\documentclass{article}
\usepackage{afterpage,everypage}
\usepackage{mwe,lipsum}
\ifodd\value{page}\else\afterpage{\includegraphics{example-image-a}\vspace{2cm}}\fi}
\afterpage{\includegraphics{example-image-a}}  %  why this is necessary?
\begin{document}
test\footnote{\lipsum\lipsum}
\lipsum

\lipsum

\lipsum

\lipsum

\lipsum

\end{document}

• Thank you for your answer! (+1) I'm looking for a solution that works with floats and footnotes. – JPi Apr 13 '15 at 21:18

Here is a solution

\documentclass{article}
\usepackage{mwe,lipsum}
\makeatletter
\shipout \vbox{%
\vspace*{-1in}\hspace*{-1.2in}%
\includegraphics[height=\paperheight,width=\paperwidth]{example-image-a}}
\stepcounter{page}}
\makeatother
\begin{document}
test\footnote{\lipsum\lipsum}
\lipsum

\lipsum

\lipsum

\lipsum

\lipsum

\end{document}


This seems to work, loosely based on touhami's answer. Any gotchas? I'll accept touhami's answer if this is ok more generally.

\documentclass{article}
\usepackage{mwe,lipsum}
\usepackage{atbegshi}
\usepackage{pdfpages}

\newcounter{ugh}

\AtBeginShipout{%
\ifodd\value{page}{\setcounter{ugh}{\value{totalnumber}}\setcounter{totalnumber}{0}\includepdf{blank}}\else{\setcounter{totalnumber}{\value{ugh}}}\fi}

\begin{document}
test
\begin{figure}[t]
some test
\caption{some}
\end{figure}

\begin{figure}[t]
some test
\caption{some}
\end{figure}

\begin{figure}[t]
some test
\caption{some}
\end{figure}

\begin{figure}[t]
some test
\caption{some}
\end{figure}

\lipsum

\lipsum

\lipsum

\lipsum

\lipsum

\end{document}

• i will add an other solution – touhami Apr 14 '15 at 6:11