# Group content side by side possibly spanning more than a single page

I have data consisting of groups of key-value pairs and associated images. I'd like the key-value pairs to show in a table to the right of the images. Like this:

The above screenshot is produced by the following code:

\begin{minipage}[t]{.4\textwidth}
\vspace{0pt}
\includegraphics[width=\textwidth]{image}
\includegraphics[width=\textwidth]{image}
\end{minipage}
\begin{minipage}[t]{.55\textwidth}
\vspace{0pt}
\begin{tabular}{ >{\bfseries \raggedleft}p{0.4\textwidth}<{:}  p{.6\textwidth}  }
Key & Value \\
Another key & 56.1481049 \\
Ipsum bla & Lorem tutasee \\
Kvalatit & Tip top \\
Fordus tius & Lorem ipsum bla supresium vitales ektum eksaput doktinus mit dei fyrte granikus.\\
Estimat is & 1337 \\
Lokale & Viktualierum \\
\end{tabular}
\end{minipage}


The code works as I want and several groups of tables and images can be placed after each other.

However unfortunately it seems that a minipage is restricted to a single page. Thus, if the images or the table takes more space than a single page, they will simply overflow the page and continue on into non-existence.

Is there any way that I can achieve what I want in a way so that if possible the tables aren't broken across several pages but in the cases where the minipages simply can't fit in a page they behave decently?

The above is a rough illustration of what I'd like to end op with. That is: the tabels/images only breaks on pages when they have to, otherwise they act like normal LaTeX floats.

-
neither the minipage nor the nested tabular (if you removed the minipage) will break over a page, It looks like you want a list for the text (which will break over a page) then put the images in the margin using \marginpar or similar (with a wide left margin) –  David Carlisle Jan 8 at 13:24
But i only want the things to break over a page when the content is longer than a page and absolutely has to. –  paldepind Jan 8 at 13:42
so you can set the inter-line penalties within the list to be very high. –  David Carlisle Jan 8 at 13:59
Could maybe create and answer with an example? I've no experience with penalties and I'm not sure how you'll get the same look for the key-value pairs with a list? –  paldepind Jan 14 at 11:59
I would have thought about \marginnote{} the illustrations at places where you want them. As far as I remember, you might want then to have a smaller textwidth but more margin... That's my current idea. –  strpeter Jan 29 at 21:06

You could take advantage of the new scrlayer packages in the new KOMA-script version (3.12). The column in the margin will continue, if necessary, on the next page. To me, this seems something rather new. However, you'd need longtable and I did not really test that. Just as an example I add some code, but you'll have to play with the width and the margins...

\documentclass[pagesize]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{scrlayer-notecolumn, scrlayer-scrpage, graphicx, calc, longtable}

\DeclareNewNoteColumn[font=\sffamily\footnotesize, width=3cm,
position=\oddsidemargin+1in+\textwidth-3cm+\marginparsep]{randnot}

\begin{document}
\makenote[randnot]{%
\protect\begin{longtable}{p{1.5cm}p{2cm} }
Key & Value \\
Another key & 56.1481049 \\
Ipsum bla & Lorem tutasee \\
Kvalatit & Tip top \\
Fordus tius & Lorem ipsum bla supresium vitales ektum eksaput doktinus mit dei fyrte granikus.\\
Estimat is & 1337 \\
Lokale & Viktualierum \\
\protect\end{longtable} }
\includegraphics[width=\textwidth]{image}%
\end{document}

-
Hm, I'm not sure that the version of KOMA-script you mention is available to me (I'm using texlive from the Ubuntu repos). –  paldepind Jan 10 at 11:10
@paldepind This should be interesting for you: How to install “vanilla” TeXLive on Debian or Ubuntu? –  Speravir Jan 21 at 17:52
Alex, better use an image from package mwe, and perhaps add package showframe, so one can see better the overlapping of margin. –  Speravir Jan 21 at 23:14
Sorry. I've played around with your code, and I can not get it to display properly. –  paldepind Jan 29 at 12:52
@paldepind No need to be sorry, but this code runs on my machine so probably your installations includes older versions of KOMA-script files. \listfiles at the beginning of the code will print all files into the log and you can look out for the culprit. –  Keks Dose Jan 29 at 13:11

Here's a fairly simplistic solution using longtable, together with adjustbox to help with vertical alignment of the figures.

I have used a simple itemize list for your 'key-value' list, and used the enumitem to help with the formatting of it.

Note that the longtable environment will never break cells across pages, but will happily put page breaks between rows, which sounded like it was your main goal- the output should be almost exactly as it is in your mock-up, although you may get some bad pagination depending on the dimensions of your images.

% arara: pdflatex
% !arara: indent: {overwrite: yes, trace: yes, localSettings: yes}
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{longtable}
\usepackage{graphicx}
\usepackage{enumitem}

\begin{document}

\begin{longtable}{p{.4\textwidth}p{.6\textwidth}}
\includegraphics[width=\linewidth,valign=t]{example-image-a}
\includegraphics[width=\linewidth,valign=t]{example-image-b}
&
\begin{itemize}[font=\bfseries,leftmargin=2.5cm]
\item[Key] Value
\item[Another key] 56.1481049
\item[Ipsum bla] Lorem tutasee
\item[Kvalatit] Tip top
\item[Fordus tius] Lorem ipsum bla supresium vitales
ektum eksaput doktinus mit dei fyrte granikus.
\item[Estimat is] 1337
\item[Lokale] Viktualierum
\end{itemize}
\end{longtable}
\end{document}

-
The longtable you're using here has only a single row per data/image set. Doesn't this mean that this solution has the exactly same problem as my original one if one set of data or images takes up more space than a page? –  paldepind Feb 6 at 7:04
@paldepind you're correct, it does have that limitation. The mark up is slightly more robust in my solution because we don't have to specify a minipage every time, and we only have to specify the column widths once. If you have a set of data that takes up more than a page, you're going to have to tweak it manually; perhaps you might be interested in grid typesetting. Thanks for the bounty, I appreciate it :) –  cmhughes Feb 6 at 17:29
Unfortunately manual tweaking is not an option for me since the LaTeX file is automatically generated based on data from a database. –  paldepind Feb 7 at 14:11