2

I'm trying to accomplish "threeparttables" while simultaneously using both makecell (to achieve within-cell rowbreaks) and tabulary (to make the tables not exceed \linewidth). But while I can achieve threeparttables with tabulary that don't use makecell (first code example below) and tables with tabulary that use makecell but not threeparttable (second code example below), I can't build a document that combines the three (third example). What to do?

I am aware that using tabularx instead of tabulary builds this particular table, but I have lots of these tables. I would prefer not to check each table separately but instead use tabulary. Also, I am not married to using makecell but I need to be able to have rowbreaks within cells (and to control their vertical alignment).

Any help would be much appreciated!

First example (threeparttable and tabular but no makecell)

\documentclass{article}
\usepackage[para]{threeparttable}
\usepackage{tabulary}
\begin{document}
  \begin{table}
    \begin{threeparttable}
      \caption{Lorem ipsum dolor sit amet, consectetur}

      {
        \begin{tabulary}{\linewidth}{L r L r}
        \textbf{Aaa} & \textbf{Bbb} & \textbf{Ccc} \tabularnewline
         & & Ccc1 & Ccc2 \tabularnewline
        Adipisicing elit, sed do eiusmod tempor & \(0.40\) & Ut labore et dolore magna aliqua & \(7.77\) \tabularnewline
        Ut enim ad minim veniam, quis nostrud exercitation & \(0.93\) & Ullamco laboris nisi ut aliquip ex ea commodo consequat & \(62.6\) \tabularnewline
        \end{tabulary}
      }
    \end{tablenotes}
  \end{threeparttable}
\end{document}

Second example (tabulary and makecell but no threeparttable

\documentclass{article}
\usepackage{tabulary}
\usepackage{makecell}
\begin{document}
  \begin{table}
    \caption{Lorem ipsum dolor sit amet, consectetur}

    {
      \begin{tabulary}{\linewidth}{L r L r}
      \textbf{Aaa} & \textbf{Bbb} & \textbf{Ccc} \tabularnewline
       & & \makecell{Ccc1} & \makecell{Ccc2 \\ Ccc2} \tabularnewline
      Adipisicing elit, sed do eiusmod tempor & \(0.40\) & Ut labore et dolore magna aliqua & \(7.77\) \tabularnewline
      Ut enim ad minim veniam, quis nostrud exercitation & \(0.93\) & Ullamco laboris nisi ut aliquip ex ea commodo consequat & \(62.6\) \tabularnewline
      \end{tabulary}
    }
  \end{table}
\end{document}

Third example (all three, not working)

\documentclass{article}
\usepackage[para]{threeparttable}
\usepackage{tabulary}
\usepackage{makecell}
\begin{document}
  \begin{table}
    \begin{threeparttable}
      \caption{Lorem ipsum dolor sit amet, consectetur}

      {
        \begin{tabulary}{\linewidth}{L r L r}
        \textbf{Aaa} & \textbf{Bbb} & \textbf{Ccc} \tabularnewline
         & & \makecell{Ccc1} & \makecell{Ccc2 \\ Ccc2} \tabularnewline
        Adipisicing elit, sed do eiusmod tempor & \(0.40\) & Ut labore et dolore magna aliqua & \(7.77\) \tabularnewline
        Ut enim ad minim veniam, quis nostrud exercitation & \(0.93\) & Ullamco laboris nisi ut aliquip ex ea commodo consequat & \(62.6\) \tabularnewline
        \end{tabulary}
      }

      \begin{tablenotes}
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      \end{tablenotes}
    \end{threeparttable}
  \end{table}
\end{document}

1 Answer 1

2

You can replace \makecell with the \Centerstack command from stackengine, which doesn't have a conflict with other packages:

\usepackage[latin]{babel} 
\usepackage[para]{threeparttable}
\usepackage{tabulary}
\usepackage[usestackEOL]{stackengine}

\begin{document}

  \begin{table}
    \begin{threeparttable}
      \caption{Lorem ipsum dolor sit amet, consectetur}

      {
        \begin{tabulary}{\linewidth}{L r L r}
        \textbf{Aaa} & \textbf{Bbb} & \textbf{Ccc} \tabularnewline
         & & \Centerstack{Ccc1} & \Centerstack{Ccc2\\ Ccc2} \tabularnewline
        Adipisicing elit, sed do eiusmod tempor & \(0.40\) & Ut labore et dolore magna aliqua & \(7.77\) \tabularnewline
        Ut enim ad minim veniam, quis nostrud exercitation & \(0.93\) & Ullamco laboris nisi ut aliquip ex ea commodo consequat & \(62.6\) \tabularnewline
        \end{tabulary}
      }

      \begin{tablenotes}\footnotesize
        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
      \end{tablenotes}
    \end{threeparttable}
  \end{table}

\end{document} 

enter image description here

1
  • When this (or \Longunderstack that I ended up using) is combined with \strutlongstacks{T}, it looks just like what I intended :)
    – Fredrik P
    Commented Oct 4, 2020 at 8:39

You must log in to answer this question.

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