1

In the paper I'm working on I need to insert an image (.png) of a quite long timeline graph.

At first I tried to make it fit on the page by simply rotating the page in landscape mode (package pdflscape), but the resulting indexes were way too small to be read properly (A4 page).

So I thought that a convenient solution could be making two separate graphs (splitting the data) and inserting them in two consecutive vertically oriented pages... but how?

The majority of the questions I've seen on the topic of "splitting images" don't address this kind of operation. I've looked at How to include a picture over two pages, left part on left side, right on right (for books)? thread and read the hvfloat package documentation, but they both employ an automatic way of splitting images that doesn't work well with technical graphs (it's nice with photos and such though). The closest I've gotten to the result I'm looking for is visible at pages 90-91 of the hvfloat package documentation (the code is on page 88).

To sum up the problem:

  • I need two parts of the same image (graph) to appear on two empty (without text) consecutive pages, the first part on the left page and the second part on the right page;
  • the images should scale as to cover the maximum width of the page, but not exceeding its margins (e.g. \includegraphics[width=\columnwidth]{Figure1.png});
  • when printed, the two images need to be perfectly aligned with each other, and by doing so, reassemble the graph. In other words, the images must be in adjacent pages both visible with a single glance (without flipping any page).
  • The caption should be on the top of the (first) image.

I cannot provide any meaningful MWE for what I'm asking. Anyways, hoping to save you some time, here's my simple document setup and two test images to work with:

\documentclass[12pt, a4paper, twoside, english]{book}
\usepackage[a4paper, lmargin=3cm, rmargin=2cm, tmargin=2cm, bmargin=2cm]{geometry}
\usepackage{graphicx}
    \graphicspath{ {./Images/} }

\begin{document}

% I need this on the first page. \begin{figure} \caption{Diachronic representation (1900-1950).} \centering \fbox{\includegraphics[width=\columnwidth]{Images/diachronic_graph_part1.png}} \label{graph:dr1} \end{figure}

% And this on the second page. \begin{figure} \caption{Diachronic representation (1951-2000).} \centering \fbox{\includegraphics[width=\columnwidth]{Images/diachronic_graph_part2.png}} \label{graph:dr2} \end{figure}

\end{document}

First part of the graph

Second part of the graph

Thank you in advance!

Any other related suggestion is welcomed.

  • If you specifiy [p] figures, no text will be included. You may need to increase the height of the figures to at least 0.5\textheight so that they don't both show up on the same page. If they are the same height, they should be aligned. If not, you can use \raisebox optional arguments to fake it. – John Kormylo Oct 11 '23 at 11:24
  • Or specify the height instead of the width in \includegraphics. – John Kormylo Oct 11 '23 at 11:32
  • @JohnKormylo the problem with this solution is that the original graph is distorted when stretched by its height (0.5\textheight) – Literary Locust Oct 11 '23 at 14:40

2 Answers2

1

This assumes that the images were originally the same height but not the same width.

\documentclass[12pt, a4paper, twoside, english]{book}
\usepackage[a4paper, lmargin=3cm, rmargin=2cm, tmargin=2cm, bmargin=2cm]{geometry}
\usepackage{graphicx}
%    \graphicspath{ {./Images/} }% /Images/Images/... ???

\newsavebox{\tempboxa} \newsavebox{\tempboxb} \newlength{\myheight}

\begin{document}

% compare images \savebox{\tempboxa}{\includegraphics[width={\dimexpr \columnwidth-2\fboxsep-2\fboxrule}]{example-image-a}} %Images/diachronic_graph_part1.png \savebox{\tempboxb}{\includegraphics[width={\dimexpr \columnwidth-2\fboxsep-2\fboxrule}]{example-image-b}} %Images/diachronic_graph_part2.png \ifdim\ht\tempboxa>\ht\tempboxb% use smaller height \myheight=\ht\tempboxb \else \myheight=\ht\tempboxa \fi

% I need this on the first page. \begin{figure}[p] \begin{minipage}[c][\textheight][c]{\textwidth} \caption{Diachronic representation (1900-1950).} \centering \fbox{\resizebox{!}{\myheight}{\usebox\tempboxa}} \label{graph:dr1} \end{minipage} \end{figure}

% And this on the second page. \begin{figure}[p] \begin{minipage}[c][\textheight][c]{\textwidth} \caption{Diachronic representation (1951-2000).} \centering \fbox{\resizebox{!}{\myheight}{\usebox\tempboxb}} \label{graph:dr2} \end{minipage} \end{figure}

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • This doesn't work. The two images are still on the same page, one above the other. Their scaling is right though. – Literary Locust Oct 11 '23 at 14:43
  • Not a problem. The optional arguments for minipage can be used to specify the height, so that figure thinks you are using the whole page. – John Kormylo Oct 11 '23 at 18:35
1
\documentclass[12pt, a4paper, twoside, english]{book}
\usepackage[a4paper, lmargin=3cm, rmargin=2cm, tmargin=2cm, bmargin=2cm]{geometry}
\usepackage{graphicx,afterpage}
\usepackage{blindtext}

\begin{document}

\Blindtext\clearpage% to get next page as even number   

\begin{figure}[!t]
    \caption{Diachronic representation (1900-1950).}
    \centering
    \fbox{\includegraphics[width=\dimexpr\columnwidth-2\fboxsep-2\fboxrule]{/tmp/i1}}
    \label{graph:dr1}
    \end{figure}

\afterpage{\clearpage}

\Blindtext[5]

% And this on the second page.
\begin{figure}[!t]
    \caption{Diachronic representation (1951-2000).}
    \centering
    \fbox{\includegraphics[width=\dimexpr\columnwidth-2\fboxsep-2\fboxrule]{/tmp/i2}}
    \label{graph:dr2}
    \end{figure}

\Blindtext[5]   
\end{document}

enter image description here

user187802
  • 16,850