tables – Creating Multipage Cells with Tabularray in LaTeX

longtablemiktextablestabularray

I am trying to create automated machine logs and I am failing because the contents for a cell of the table do not fit on one page. Is there a simple way to allow page breaks within individual cells? The page break between cells works perfectly, but cells larger than the page height make problems…
The following code illustrates the problem (text flows beyond the bottom of the page):

[MikTeX / Windows environment]

\documentclass[a4paper, 8pt]{article}
\usepackage[a4paper, left=15mm, right=15mm, top=45mm, bottom=35mm]{geometry}
\usepackage[ngerman]{babel}

\usepackage{helvet}
\renewcommand{\familydefault}{\sfdefault}

\usepackage{sectsty}
\usepackage{blindtext}
\usepackage{tabularray}

\begin{document}
\section{Einleitung}
\label{Einleitung}

\begin{flushleft}
Beispieltext
\newline
\begin{longtblr}[
entry=none
]{
width=\textwidth,
colspec = {X[l,t] X[l,t,70mm] X[l,t,70mm] X[l,t,14mm]},
rowhead = 1,
rowfoot = 0,
hline{2}={2pt, solid},
hline{3-Y}={1pt, solid},
vline{2-Y}={1pt, solid},
row{1} = {font=\bfseries},
}
{S1} & {S2} & {S3} & {S4} \\
{1} & {\blindtext[4]} & {\blindtext} & { - }\\
\end{longtblr}
\end{flushleft}
\end{document}

Screenshot of the generated pdf

If there is no easy solution, I could change the paper size to A3, but that would not be an ideal solution.

Thank you!

Best Answer

It's possible to simulate a table in which cell would span multiple pages. As suggested, the main package would be paracol because in this environment paragraphs can continue on following pages. However, every row would have to be a separate paracol environment. You can separate rows either with extra space or a rule. The limit however is you would have to give up on vertical lines. A caption can be simulated by \captionof{table}{...} (requires caption).

The example below combines all the above. I'd consider using \RaggedRight instead of \raggedright for more balanced texts in narrow columns (requires ragged2e package).

\documentclass{article}
\usepackage{geometry}
\usepackage{paracol}
\usepackage{caption}
\usepackage{ragged2e}
\usepackage{kantlipsum}


\begin{document}
\kant[10]

\begingroup
%%% Setup column ratios for paracol
\columnratio{0.04, 0.46, 0.46}
\definecolumnpreamble{1}{\RaggedRight}
%%% Caption
\medskip
\captionof{table}{Caption}
\rule[0.4ex]{\linewidth}{0.8pt}
\begin{paracol}{4}
  S1
  \switchcolumn
  S2
  \switchcolumn
  S3
  \switchcolumn
  S4
\end{paracol}
\rule[1ex]{\linewidth}{0.5pt}%
\begin{paracol}{4}
  1
  \switchcolumn
  \kant[1]
  \switchcolumn
  \kant[2-3]
\end{paracol}
\rule[0.4ex]{\linewidth}{0.5pt}
\begin{paracol}{4}
  2
  \switchcolumn
  \kant[3-5]
  \switchcolumn
  \kant[8-9]
  \switchcolumn
  3
\end{paracol}
\rule[0.4ex]{\linewidth}{0.8pt}\medskip
\endgroup

\kant[11]
\end{document}

enter image description here