[Tex/LaTex] Making a tabular span multiple pages – package interaction prevents longtable as a drop-in replacement

tables

I have a tabular which relies on a number of packages to achieve the desired appearance, specifically:

  • Scale text to a particular (smaller) size
  • Force column wrapping instead of shrinking text further
  • Increase space between different rows to distinguish between wrapped items
  • Disable right justification and hyphenation for a tidier look

I discovered that the table will end up needing to span multiple pages, but in this situation longtable is not a drop-in replacement for tabular and I am getting confused with the number of packages involved. How can I achieve the desired effect (a tabular spanning multiple pages, with all other visual elements, including the float caption, retained)? As a second question, can what I've written be simplified in some way?

\documentclass{scrartcl}
\usepackage{booktabs,array,parskip,adjustbox,enumitem}
\usepackage[UKenglish]{babel}
\newcolumntype{x}[1]{>{\raggedright}p{#1}}
\begin{document}


\begin{table}
\begin{hyphenrules}{nohyphenation}
\renewcommand{\arraystretch}{1.5}
\caption{Example table}\label{tab:example}
\centering
\begin{adjustbox}{width=1\textwidth}
\begin{tabular}{x{.2\columnwidth}@{\hskip 6\tabcolsep}x{.4\columnwidth}@{\hskip 6\tabcolsep}x{.4\columnwidth}}
\toprule
{\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}}
\tabularnewline
\midrule

ABC &
\begin{itemize}[leftmargin=*]
\item This is an item in column two.
\item This is another item in column two.
\end{itemize} &
\begin{itemize}[leftmargin=*]
\item Here is something in column three:
  \begin{itemize}
  \item It
  \item consists
  \item of
  \item many
  \item different
  \item lines
  \end{itemize}
\end{itemize}
\tabularnewline

DEF &
\begin{itemize}[leftmargin=*]
\item Additional blah blah making for a long sentence spanning multiple lines.
\item Another item.
\item Continuing the theme of items in column two.
\end{itemize} &
\begin{itemize}[leftmargin=*]
\item Here we also have a rather long item that needs multiple lines to fit.
\item Yet another item.
\item Blah, blah:
  \begin{itemize}
  \item It's a very long example of a sub-item in this column, here
  \item Yet more
  \end{itemize}
\end{itemize} 
\tabularnewline

GHI &
\begin{itemize}[leftmargin=*]
\item Another long, long long long long long long long long long long long
block of text.
\item This particular one is medium-medium medium in lenght.
\item This sentence means nothing in particular, it's blah.
\end{itemize} &
\begin{itemize}[leftmargin=*]
\item Blah
\end{itemize} 
\tabularnewline

JKL &
\begin{itemize}[leftmargin=*]
\item Blah, blah, blah, blah, blah.
\item Putting in fake data gets tedious.
\item Reading it is probably more boring still.
\end{itemize} &
\begin{itemize}[leftmargin=*]
\item Blah
\end{itemize}
\tabularnewline

MNO &
\begin{itemize}[leftmargin=*]
\item This was also a really long item so I am going to type and type and
type until I run out of words.
\end{itemize} &
\begin{itemize}[leftmargin=*]
\item Blah
\item Can
\item we
\item span
\item multiple
\item pages
\item with
\item lots
\item of
\item text?
\item Becauase
\item this
\item really
\item needs
\item to
\item be
\item multipage.
\end{itemize}
\tabularnewline

\bottomrule
\end{tabular}
\end{adjustbox}
\renewcommand{\arraystretch}{1}
\end{hyphenrules}
\end{table}

\end{document}

Output of LaTeX example

Best Answer

The first page:

enter image description here

The second page:

enter image description here

MWE (in preamble are considered only used packages):

\documentclass{scrartcl}

\usepackage{enumitem}
\usepackage{array, booktabs, longtable}
\newcolumntype{x}[1]{>{\raggedright}p{#1}}

\usepackage{etoolbox}
\AtBeginEnvironment{longtable}{%
    \setlist[itemize]{nosep,     % <-- new list setup
                      topsep     = 0pt       ,
                      partopsep  = 0pt       ,
                      leftmargin = *         ,
                      label      = $\bullet$ ,
                      before     = \vspace{-\baselineskip},
                      after      = \vspace{-0.5\baselineskip}
                        }
                           }% end of AtBeginEnvironment

%\usepackage{showframe}
\begin{document}
%\renewcommand{\arraystretch}{1.5}
\begin{longtable}{x{\dimexpr.2\columnwidth-2\tabcolsep}
                  x{\dimexpr.4\columnwidth-2\tabcolsep}
                  x{\dimexpr.4\columnwidth-2\tabcolsep}}
%\begin{hyphenrules}{nohyphenation}
    \caption{Example table}\label{tab:example}  \\
\toprule
{\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}}
\tabularnewline
\midrule
    \endfirsthead
%%%%
    \caption{Example table (cont.)}\label{tab:example}  \\
\toprule
{\textbf{Column One}} & {\textbf{Column Two}} & {\textbf{Column Three}}
\tabularnewline
\midrule
    \endhead
%%%%
\midrule[\heavyrulewidth]
\multicolumn{3}{r}{\footnotesize\itshape
                   Continue on the next page}
    \endfoot
%%%%
\bottomrule
    \endlastfoot
%%%%
ABC &
\begin{itemize}
\item This is an item in column two.
\item This is another item in column two.
\end{itemize} &
\begin{itemize}
\item Here is something in column three:
    \bigskip
  \begin{itemize}
  \item It
  \item consists
  \item of
  \item many
  \item different
  \item lines
  \end{itemize}
\end{itemize}
\tabularnewline\addlinespace

DEF &
\begin{itemize}
\item Additional blah blah making for a long sentence spanning multiple lines.
\item Another item.
\item Continuing the theme of items in column two.
\end{itemize} &
\begin{itemize}
\item Here we also have a rather long item that needs multiple lines to fit.
\item Yet another item.
\item Blah, blah:
    \bigskip
  \begin{itemize}
  \item It's a very long example of a sub-item in this column, here
  \item Yet more
  \end{itemize}
\end{itemize}
\tabularnewline\addlinespace

GHI &
\begin{itemize}
\item Another long, long long long long long long long long long long long
block of text.
\item This particular one is medium-medium medium in lenght.
\item This sentence means nothing in particular, it's blah.
\end{itemize} &
\begin{itemize}
\item Blah
\end{itemize}
\tabularnewline\addlinespace

JKL &
\begin{itemize}
\item Blah, blah, blah, blah, blah.
\item Putting in fake data gets tedious.
\item Reading it is probably more boring still.
\end{itemize} &
\begin{itemize}
\item Blah
\end{itemize}
\tabularnewline\addlinespace

MNO &
\begin{itemize}
\item This was also a really long item so I am going to type and type and
type until I run out of words.
\end{itemize} &
\begin{itemize}
\item Blah
\item Can
\item we
\item span
\item multiple
\item pages
\item with
\item lots
\item of
\item text?
\item Becauase
\item this
\item really
\item needs
\item to
\item be
\item multipage.
\end{itemize}
\tabularnewline
\end{longtable}
Related Question