130

When writing a long book (from 300 to over a 1000 pages), there is often need to include large pictures and one wishes to have them displayed over two pages, left half on the left page, right half on the right page. If one cuts the picture in two halves and includes them both separately, there is a large possibility that they will not end up each on their respective page (i.e. next to each other).

If there are many many pictures to be added (from 50 to up to 200 pictures per book), splitting each picture in two halves manually is not acceptable, especially if a tiny change in font size shifts the whole document, resulting in a big mess with pictures: the left part now appears on the right page side and vice versa.

Question: How can I create a command

\twopagepicture{position = t or b}{width = l or p}{mypicture.jpg}

with the following properties:

  • t ... top of page
  • b ... bottom of page
  • l ... line width
  • p ... page width

the left half of the picture is displayed on the left page (nearest to the place/text where the command was called) and the right half on the NEXT (right) page.

For example \twopagepicture{t}{l}{mypicture.jpg} is supposed to do this:

enter image description here

And \twopagepicture{t}{p}{mypicture.jpg} is supposed to do this:

enter image description here

By the way, I'm using memoir with a lot of packages:

\documentclass[a4paper,twoside, openodd, final]{memoir}
\usepackage[english]{babel}
\usepackage[top=2.4cm, bottom=2cm, left=2cm, right=2cm]{geometry}
\usepackage{bookman}
\usepackage[pdfpagelayout=TwoPageRight]{hyperref}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{verbatim}
\usepackage{color}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{wrapfig}
\usepackage{fancybox}
\usepackage{framed}
\usepackage{lettrine}
\usepackage{tocloft}
\usepackage{pdfpages}
\usepackage{watermark}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makechapterstyle{LOTRchapter}{ \renewcommand{\chapterheadstart}{\vspace*{\beforechapskip}\hrule\medskip}           %%
                                \renewcommand{\chapnamefont}{    \fontsize{10mm}{15mm}\selectfont \bfseries}        %%
                                \renewcommand{\chapnumfont}{     \fontsize{10mm}{15mm}\selectfont \bfseries}        %%
                                \renewcommand{\chaptitlefont}{   \fontsize{10mm}{15mm}\selectfont \bfseries}        %%
                                \renewcommand{\printchaptername}{\fontsize{10mm}{15mm}\selectfont \bfseries Chapter}%%
                                \renewcommand{\chapternamenum}{ }                                                   %%
                                \renewcommand{\printchapternum}{\chapnumfont \thechapter}                           %%
                                \renewcommand{\afterchapternum}{. \\}                                               %%
                                \renewcommand{\afterchaptertitle}{\par\nobreak\medskip\hrule\vskip \afterchapskip}  %%
                              }    %definiramo izgled chapterjev (deluje samo v memoir class-u)                     %%
\chapterstyle{LOTRchapter}  %uporabimo pravkar definirani stil chapterjev                                           %%
%%------------------------------------------------------------------------------------------------------------------%%
\setlength{\parindent}{0.75cm}     %zacetni zamik paragrafov                                                        %%
\setlength{\parskip}{0ex}          %vertikalni razmik med paragrafi (stevilo vrstic)                                %%
                                   %\par ... nov paragraf                                                           %%
\def\thechapter{\arabic{chapter}}  %stevilcenje chapterjev z arabskimi stevilkami                                   %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
    \includepdf[pages={-}]{Cover.pdf}
    \leftwatermark{ \put(-56.1,-795){\includegraphics[width=\paperwidth, height=\paperheight]{Background-22.jpg}}}
    \rightwatermark{\put(-56.1,-795){\includegraphics[width=\paperwidth, height=\paperheight]{Background-11.jpg}}} 
1
  • 5
    FYI, memoir already emulates tabularx and verbatim, and (with study) will eliminate your need for geometry and tocloft... Commented Sep 14, 2011 at 19:09

2 Answers 2

134

The following should do it. It needs at least two compiler runs to be stable. With a lot of floats it can take several compilation runs until the document is stable.

Updates:

Works now for twoside mode; now with caption support; Added float settings and removed ! from the float position to also support smaller images; Moved p images to the page corners.

\documentclass[twoside]{book}

\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{afterpage}
\usepackage{placeins}
\usepackage{xcolor}

% For the `memoir` class remove the following two packages.
% This class already provide the functionality of both
\usepackage{caption}
\usepackage[strict]{changepage}
%%%

\setcounter{totalnumber}{1}
\setcounter{topnumber}{1}
\setcounter{bottomnumber}{1}
\renewcommand{\topfraction}{.99}
\renewcommand{\bottomfraction}{.99}
\renewcommand{\textfraction}{.01}

\makeatletter
\newcommand*{\twopagepicture}[4]{%
    \checkoddpage
    \ifoddpage
        \expandafter\@firstofone
    \else
        \expandafter\afterpage
    \fi
    {\afterpage{%
    \if #1t%
        \if #2p%
            \thispagestyle{empty}%
            \afterpage{\thispagestyle{empty}}%
        \fi
    \fi
    \begin{figure}[#1]
        \if #2p%
            \if #1t%
                \vspace*{-\dimexpr1in+\voffset+\topmargin+\headheight+\headsep\relax}%
            \fi
        \fi
        \if #1b%
            \caption{#4}%
        \fi
        \makebox[\textwidth][l]{%
        \if #2p\relax
            \let\mywidth\paperwidth
            \hskip-\dimexpr1in+\hoffset+\evensidemargin\relax
        \else
            \let\mywidth\linewidth
        \fi
        \adjustbox{trim=0 0 {.5\width} 0,clip}{\includegraphics[width=2\mywidth]{#3}}}%
        \if #1b\else
            \caption{#4}%
        \fi
        \if #2p%
            \if #1b%
                \vspace*{-\dimexpr\paperheight-\textheight-1in-\voffset-\topmargin-\headheight-\headsep\relax}%
            \fi
        \fi
    \end{figure}%
    \begin{figure}[#1]
        \if #2p%
            \if #1t%
                \vspace*{-\dimexpr1in+\voffset+\topmargin+\headheight+\headsep\relax}%
            \fi
        \fi
        \makebox[\textwidth][l]{%
        \if #2p%
            \let\mywidth\paperwidth
            \hskip-\dimexpr1in+\hoffset+\oddsidemargin\relax
        \else
            \let\mywidth\linewidth
        \fi
        \adjustbox{trim={.5\width} 0 0 0,clip}{\includegraphics[width=2\mywidth]{#3}}}%
        \if #2p%
            \if #1b%
                \vspace*{-\dimexpr\paperheight-\textheight-1in-\voffset-\topmargin-\headheight-\headsep\relax}%
            \fi
        \fi
    \end{figure}%
    }}%
}
\makeatother

\usepackage{lipsum}
\begin{document}
\lipsum
\lipsum
\twopagepicture{b}{l}{image}{Test}
\lipsum
\twopagepicture{t}{l}{image}{Test}
\lipsum
\twopagepicture{b}{p}{image}{Other test}
\lipsum
\twopagepicture{t}{p}{image}{Other test with 
very very very very very very very very very very very
very very very very very very very very very very very
very very very very very very very very very very very
long caption
}
\lipsum
\lipsum

\end{document}

Result

(The image shown is a panorama photo made by me from top of the Preikestolen mountain, Norway)

22
  • 1
    You are a little box of magic :). Thank you so much, this means a lot to me. Your code now seems to be working very nice. The only problem remaining is that when I use the code in my actual book file, I get a Option clash for package changepage, but do not concern yourself with that. I'll try to fix the problem with my friend who knows a bit more TeX than me. I would only like to ask you to check this page in the following two days, in case we're still stuck with the problem and asking for help. Again, thank you very very very much :).
    – Leo
    Commented Jul 23, 2011 at 1:38
  • 8
    @Leon: For memoir simply remove the changepage and the caption package, then it should work fine! Commented Jul 23, 2011 at 1:40
  • 22
    Very nice. This might deserve a new package :-)
    – raphink
    Commented Sep 14, 2011 at 8:09
  • 15
    I second the idea of turning this into a new package. There is, however, one additional option I would like to see (and you had asked about in your first comment): The possibility to typeset long captions over both sides. IMHO this gives a smoother layout; furthermore I have several large facing-pages figures with long captions that otherwise do not fit on the pages. (I have achieved this more or less manually so far)
    – Daniel
    Commented Sep 14, 2011 at 9:39
  • 1
    @Daniel: I third that. Commented Sep 2, 2017 at 16:45
9

As of mid-2021, a new version of the package hvfloat, by Herbert Voß, has been available on CTAN.

In addition to the ability to split wide pictures onto two facing pages, this package can rotate images and captions, and handle both single- and two-column pages with ordinary floats and the * forms.

A well-illustrated article appears in TUGboat 42:3; until the first issue of volume 43 appears in spring of 2022, this is accessible only to TUG members.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .