1

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?

JPi
  • 13,595
  • 1
    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
  • 1
    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 page with image is it of empty style (just blank) or of special style – touhami Apr 13 '15 at 22:09
  • Preferably just a full page pdf image, but I'll take a completely blank page. – JPi Apr 13 '15 at 23:54
  • @JohnKormylo: It's not clear to me how flowfram would help me, but thank you. – JPi Apr 13 '15 at 23:55
  • You put flow frames on the odd pages and static frames on the even pages. The text will automaticaly flow from one odd page to the next. The static frames can all be loaded in the preamble. – John Kormylo Apr 14 '15 at 04:43

3 Answers3

1

This is a solution

\documentclass{article}
\usepackage{afterpage,everypage}
\usepackage{mwe,lipsum}
\AddEverypageHook{%
\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}
\AddEverypageHook{%
\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}
\AddEverypageHook{%
\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}
touhami
  • 19,520
  • 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
1

Here is a solution

\documentclass{article}
\usepackage{mwe,lipsum}
\makeatletter
\g@addto@macro\@outputpage{%
  \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}
touhami
  • 19,520
0

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}
JPi
  • 13,595