2

What vertical space is inserted between tabular and tablenotes environments when we use the threeparttable package? I'm trying to build a tablenotes environment that looks similar to the one from threeparttable but without most of its bells and whistles to use in Beamer, which doesn't really work with threeparttable. Alas, I find it quite hard to disentangle the source code to threeparttable.

The following MWE shows how the vertical spacing between the tabular and the notes is different when I use a tablenotes environment and when I use a simple \raggedright paragraph.

\documentclass{article}
\usepackage[para,flushleft]{threeparttable}
\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}
  \begin{table}[h]
    \begin{threeparttable}
      \caption{With \texttt{tablenotes} environment}
      \begin{tabularx}{\linewidth}{@{}Xccc@{}}
        \toprule
        & A & B & C \\
        \midrule
        First row heading  & 123 & 456 & 789 \\
        Second row heading & 123 & 456 & 789 \\
        Third row heading  & 123 & 456 & 789 \\
        \bottomrule
      \end{tabularx}
      \begin{tablenotes}
        \emph{Note:} Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
      \end{tablenotes}
    \end{threeparttable}
  \end{table}
  \clearpage
  \begin{table}[h]
    \begin{threeparttable}
      \caption{Without \texttt{tablenotes} environment}
      \begin{tabularx}{\linewidth}{@{}Xccc@{}}
        \toprule
        & A & B & C \\
        \midrule
        First row heading  & 123 & 456 & 789 \\
        Second row heading & 123 & 456 & 789 \\
        Third row heading  & 123 & 456 & 789 \\
        \bottomrule
      \end{tabularx}
      \raggedright \emph{Note:} Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod\par
    \end{threeparttable}
  \end{table}
\end{document}

Animated output from MWE

7
  • It seems to be introduced by a simple \par.
    – Bernard
    Jul 22, 2021 at 20:42
  • 2
    I can replicate the issue you've come across with tabularx and tabular* environments, but not with tabular environments. Maybe the issue isn't related to the tablenotes environment but, instead, to the way tabularx and tabular* are defined.
    – Mico
    Jul 23, 2021 at 5:05
  • 1
    @Mico If I remove the threeparttable environment and just use my \raggedright line, then the vertical spacing is just as in the second table from the MWE irrespective of whether I use tabularx, tabular*, tabular or tabulary. So, the vertical space is introduced by threeparttable but the package seems to treat tabularx and tabular* environments differently than it does tabular and tabulary environments.
    – Fredrik P
    Jul 23, 2021 at 12:36
  • 1
    @FredrikP - With some luck, @DavidCarlisle -- TeX and LaTeX guru extraordinaire, second-most-prolific answer provider on this site, and creator/maintainer of the tabularx package -- will notice your query and take a very close look into how the threeparttable, tabularx and tabular* are interacting and how/why their interactions are slightly different from the ways the tabular and threeparttable environments interact.
    – Mico
    Jul 23, 2021 at 13:11
  • 1
    @Mico I added the tabularx tag to further lure @DavidCarlisle to join me :-D
    – Fredrik P
    Jul 23, 2021 at 13:49

2 Answers 2

3

You may try talltblr environment (added in version 2021M on 2021-08-01) with tabularray package . There is a footsep option for setting this vertical space:

\documentclass{article}

\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}

With \texttt{talltblr} environment, default \texttt{footsep = 6pt}:

\begin{table}[h]
\begin{talltblr}[
  caption = {With \texttt{talltblr} environment},
  remark{Note} = {Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod},
]{@{}Xccc@{}}
    \toprule
    & A & B & C \\
    \midrule
    First row heading  & 123 & 456 & 789 \\
    Second row heading & 123 & 456 & 789 \\
    Third row heading  & 123 & 456 & 789 \\
    \bottomrule
\end{talltblr}
\end{table}

With \texttt{talltblr} environment, set \texttt{footsep = 0pt}:

\begin{table}[h]
\begin{talltblr}[
  caption = {With \texttt{talltblr} environment},
  remark{Note} = {Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod},
  footsep = 0pt,
]{@{}Xccc@{}}
    \toprule
    & A & B & C \\
    \midrule
    First row heading  & 123 & 456 & 789 \\
    Second row heading & 123 & 456 & 789 \\
    Third row heading  & 123 & 456 & 789 \\
    \bottomrule
\end{talltblr}
\end{table}

\end{document}

enter image description here

The same source code also works in beamer documents:

enter image description here

0

The environment {NiceTabular} of nicematrix has its own system of tabular notes. It's easy to set the vertical space before the tabular notes by putting a command \vspace in the content of the key tabularnote.

\documentclass{article}
\usepackage{nicematrix,booktabs,enumitem}

\begin{document}

\begin{table}[h]
\begin{NiceTabular}
  [tabularnote = {\vspace{5pt}Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod}]
  {@{}Xccc@{}}
    \toprule
    & A & B & C \\
    \midrule
    First row heading  & 123\tabularnote{A note}& 456 & 789 \\
    Second row heading & 123\tabularnote{A second note}& 456 & 789 \\
    Third row heading  & 123 & 456 & 789 \\
    \bottomrule
\end{NiceTabular}
\end{table}

\end{document}

Output of the above code

The main drawback of the package nicematrix is that the tabular created by {NiceTabular} can't be broken (as, for example, in longtable or tabularray).

You must log in to answer this question.

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