1

I'm trying to use the threeparttable construction offered by the threeparttablex package, that allows one to add a note to the bottom of a longtable. However, I'd like it to be backward compatible with my earlier usage, which used a plain longtable.

Therefore, I'd like to have the option to have a threeparttable with an empty note, which then reduces to the usual longtable. However, this does not seem possible, since leaving the TableNotes section empty gives an error message. It accepts just a \item, but that adds an extra line, or at any rate, some extra space at the bottom of the table, as one can verify by comparing a threeparttable with just an \item as note (\emptythreeparttable), vs a regular longtable (\emptylongtable). I'd like to be able to have a threeparttable which looks exactly like a longtable.

So, is it possible to achieve this?

I'd also be interested in pointers to packages or constructions with similar functionality.

\documentclass[12pt]{scrartcl}
\usepackage{longtable}
\usepackage{threeparttablex}
\usepackage{booktabs}

\begin{document}

\newcommand{\emptythreeparttable} { \begin{ThreePartTable} \begin{TableNotes} \item \end{TableNotes} \begin{longtable}{l l} \toprule Column 1 & Column 2 \ \midrule \endhead \cmidrule{2-2} \multicolumn{2}{r}{\textit{continued}} \endfoot \bottomrule \insertTableNotes \endlastfoot % the contents of the table A& B\ C& D\ \end{longtable} \end{ThreePartTable} }

\newcommand{\emptylongtable} { \begin{longtable}{l l} \toprule Column 1 & Column 2 \ \midrule \endhead \cmidrule{2-2} \multicolumn{2}{r}{\textit{continued}} \endfoot \bottomrule %\insertTableNotes \endlastfoot % the contents of the table A& B\ C& D\ \end{longtable} }

%\emptythreeparttable \emptylongtable Some text.

\end{document}

Faheem Mitha
  • 7,778
  • Possibly related: https://tex.stackexchange.com/questions/359903/i-have-table-with-long-notes-in-the-longtable-and-threeparttable-environment-h – John Kormylo Jul 01 '22 at 12:14

1 Answers1

1

It should be sufficient to redefine \insertTableNotes to do nothing inside the ThreePartTable environment within your \emptythreeparttable command. If your actual use case is different from the example you've created then this may not do what you want.

\documentclass[12pt]{scrartcl}
\usepackage{longtable}
\usepackage{threeparttablex}
\usepackage{booktabs}

\begin{document}

\newcommand{\emptythreeparttable} { \begin{ThreePartTable} \renewcommand{\insertTableNotes}{} \begin{TableNotes} \item \end{TableNotes} \begin{longtable}{l l} \toprule Column 1 & Column 2 \ \midrule \endhead \cmidrule{2-2} \multicolumn{2}{r}{\textit{continued}} \endfoot \bottomrule \insertTableNotes \endlastfoot % the contents of the table A& B\ C& D\ \end{longtable} \end{ThreePartTable} }

\newcommand{\emptylongtable} { \begin{longtable}{l l} \toprule Column 1 & Column 2 \ \midrule \endhead \cmidrule{2-2} \multicolumn{2}{r}{\textit{continued}} \endfoot \bottomrule %\insertTableNotes \endlastfoot % the contents of the table A& B\ C& D\ \end{longtable} }

\emptythreeparttable \rule{\linewidth}{1pt} Some text \emptylongtable \rule{\linewidth}{1pt} Some text.

\end{document}

output of code

Alan Munn
  • 218,180
  • Hi @AlanMunn, this workaround was successful for my use case, though I think it would be better if threeparttablex degraded back to the standard table in the case that the note was empty. – Faheem Mitha Jul 12 '22 at 19:56