# longtable next to longtable [no multicolumn]

I'd like to place multiple tables (two or three) next to each other, with the following requirements:

• They need to be able to span accross pages

• They need to be aligned next to each other

• I need to be able to use csv-reader (csvsimple package) with it

At first (first draft) I used tabular environments, which worked quite well except that they can't span over multiple pages.

So I tried to switch to longtables, but it seems like longtables can't be placed "side-by-side" like tabular environments do... Is that a restriction of longtables (implementation) or is there a way to make two longtables start on the same line? (eg. by using LTleft / LTright ?)

\documentclass[]{article}
\usepackage{longtable}
\usepackage{csvsimple}
\usepackage{filecontents}

\begin{filecontents*}{results1.csv}
id, s, dBC, dWC
18,     3,  9,  12
70,     4,  13,     17
120,    5,  17,     21
170,    6,  21,     25
220,    7,  25,     29
270,    8,  29,     33
320,    9,  33,     37
\end{filecontents*}
\begin{filecontents*}{results2.csv}
id, s, dBC, dWC
18,     3,  9,  12
70,     4,  13,     17
120,    5,  17,     21
170,    6,  21,     25
220,    7,  25,     29
270,    8,  29,     33
320,    9,  33,     37
\end{filecontents*}

\begin{document}

\begin{tabular}{|c|c|}
\hline\textbf{Size} & \textbf{Data} \\\hline\hline
\hline
\end{tabular}
\begin{tabular}{|c|c|}
\hline\textbf{Size} & \textbf{Data} \\\hline\hline
\hline
\end{tabular}

\begin{longtable}{|c|c|}
\hline\textbf{Size} & \textbf{Data} \\\hline\hline
\hline
\end{longtable}
\begin{longtable}{|c|c|}
\hline\textbf{Size} & \textbf{Data} \\\hline\hline
\hline
\end{longtable}

\end{document}


PS: I need to use multiple tables, as I'm reading from two seperate csv-files. I could combine the csv-files into one and thus reduce multiple tabulars into one, but those files are auto-generated by a script and this would be a rather "last resort" solution.

PPS: Would it be possible to put multiple tabular environments into a minipage or frame and make the minipage page-break when its content does not fit the current page?

• Welcome to TeX SE! You might look at the other packages which can break tables over pages. cals says it is compatible with multicol, for example, which might be useful. I'd probably just add a script merging the files to the auto-generation routine, though. I don't see why that should be a 'last resort' option. It is just a one-off thing to add the merge step to the existing routine. So maybe something is not obvious from your description so far. – cfr Jul 27 '14 at 3:20
• There is no way to put two longtables side by side (just as you can not easily have two paragraphs side by side, both breaking at the same page break) There are many commandline tools or editors that can join two csv files to make one, and that's likely to be the easiest eg paste -d, results1.csv results2.csv on linux or cygwin/windows etc – David Carlisle Sep 23 '14 at 12:24

I think it's easier to concatenate externally, either on the commandline or here usimg

pdflatex --shell-escape


to allow latex to call out to the paste command:

I modified the 2nd csv file not to be a copy of the 1st, to check the correct data is being used.

\documentclass[]{article}
\usepackage{longtable}
\usepackage{csvsimple}
\usepackage{filecontents}

\setlength\textheight{6\baselineskip}

\begin{filecontents*}{results1.csv}
id, s, dBC, dWC
18,     3,  9,  12
70,     4,  13,     17
120,    5,  17,     21
170,    6,  21,     25
220,    7,  25,     29
270,    8,  29,     33
320,    9,  33,     37
\end{filecontents*}
\begin{filecontents*}{results2.csv}
id, s, dBC, dWC
180,     3,  90,  12
700,     4,  130,     17
1200,    5,  170,     21
1700,    6,  210,     25
2200,    7,  250,     29
2700,    8,  290,     33
3200,    9,  330,     37
\end{filecontents*}

\begin{document}

\immediate\write18{paste -d, results1.csv results2.csv > results3.csv}
\begin{longtable}{*{2}{|c|c}|}
\hline\textbf{Size} & \textbf{Data}
&\textbf{Size} & \textbf{Data}
\\\hline\hline