1

Good day, Sirs and Madams!

I am experiencing issues while composing a big table over several pages. I'd like to use tcolorbox in combination with tabularx. Unfortunately, this does not work out as expected.

It would be great if someone could help me out how to achieve a table using the stated design that stretches over several pages.

Here's the MWE:

\documentclass{article}
\usepackage{blindtext}
\usepackage{tcolorbox}
\tcbuselibrary{breakable}
\usepackage{caption}
\usepackage{array,tabularx}
\usepackage{colortbl} 
\begin{document}

\begin{figure}
\tcbset{ before=,
            after=\hfil,
            size=small,
            fonttitle=\bfseries\normalsize, 
            fontupper=\small, 
            fontlower=\small, 
            center title}
\begin{tcolorbox}[tabularx*={
\arrayrulewidth 0.5mm}{X|X|X},title=Test]
\emph{A} & \emph{B} & \emph{C}
\\\hline
A & B & C \\
\blindtext[150] & \blindtext[150] & \blindtext[150] \\
\hline
\end{tcolorbox}
\caption{Test}
\label{fig:Test}
\end{figure}
\end{document}

Any help or hints are well appreciated.

I've tried using the [breakable] option from \tcbuselibrary{breakable} but wihtout any luck.

11
  • 1
    you need longtable or ltxtable packages
    – touhami
    Commented Feb 6, 2015 at 14:17
  • 2
    A tabularx can't be split across pages.
    – egreg
    Commented Feb 6, 2015 at 14:33
  • as egreg says you can not use tabularx, but there is no need to use it anyway if the array preamble is {X|X|X} in your real example as you know the width in advance each column is p{\dimexpr(\linewidth-2\arrayrulewidth-6\tabcolsep).3\relax} Commented Feb 6, 2015 at 14:41
  • there is also the problem of figure environnement
    – touhami
    Commented Feb 6, 2015 at 14:57
  • 1
    And bad news is... tcolorbox has no long table or ltxtable options (unless Thomas does some thing in the up coming versions.)
    – user11232
    Commented Feb 6, 2015 at 15:14

1 Answer 1

6

Here is my addition to David Carlisle's answer. I sorted things a little bit different and added some options which might be useful. Especially, the right edge problem is resolved and the caption put into the title.

enter image description here

Here is the code:

\documentclass{article}
\usepackage{blindtext}
\usepackage{tcolorbox}
\tcbuselibrary{breakable,skins}
\usepackage{caption}
\usepackage{array,tabularx,longtable}
\usepackage{colortbl,lipsum}
\usepackage[margin=2cm]{geometry}
\begin{document}

\begin{tcolorbox}[
  breakable=true,
  enhanced jigsaw,
  size=small,
  fonttitle=\bfseries\normalsize,
  fontupper=\small,
  fontlower=\small,
  center title,
  title={\captionsetup{skip=0pt}\captionof{table}{Test}},
  colbacktitle=blue!10,
  colframe=blue!50!black,
  colback=yellow!10,
  label=fig:Test
  ]
\def\LTpre{0pt}%
\begin{longtable}{
@{\extracolsep{\fill}}
>{\raggedright}p{.3\linewidth}|
>{\raggedright}p{.3\linewidth}|
>{\raggedright}p{.3\linewidth}
@{}}
\emph{A} & \emph{B} & \emph{C}\tabularnewline\hline
A & B & C \tabularnewline
\blindtext[1] & \blindtext[1] & \blindtext[1] \tabularnewline
\blindtext[1] & \blindtext[1] & \blindtext[1] \tabularnewline
\blindtext[1] & \blindtext[1] & \blindtext[1] \tabularnewline
\blindtext[1] & \blindtext[1] & \blindtext[1] \tabularnewline
\blindtext[1] & \blindtext[1] & \blindtext[1] \tabularnewline
\blindtext[1] & \blindtext[1] & \blindtext[1] \tabularnewline
\blindtext[1] & \blindtext[1] & \blindtext[1] \tabularnewline
\blindtext[1] & \blindtext[1] & \blindtext[1] \tabularnewline
\end{longtable}
\end{tcolorbox}

\end{document}
2
  • The example looks splendid when using the geometry option with a margin of 2cm but in combination with the lncs template the table look weird. Do you have any advice on how to beautify the table when using lncs? Commented Feb 9, 2015 at 12:01
  • @FloatingPointZilch I'm no sure what weird means here. I just tried the Springer llncs class, but saw no specific problem (?). Commented Feb 9, 2015 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .