14

I'm using threeparttable to add table notes to a tabu tabular*. A common use case is to have a note at the end of a cell. If the note is however not added to a cell's last word, the following space is swallowed.

enter image description here

It's possible to add an \hspace after the note, as can be seen in the third row. Also, as a global workaround, one could add a space to the \tnote command's definition:

\renewcommand{\tnote}[1]{\protect\TPToverlap{\textsuperscript{\TPTtagStyle{#1}}}~}% 

The former solution is somewhat acceptable, the latter rather hackish. Is there a better way of achieving the standard \footnote behaviour of not swallowing spaces?

 

\documentclass{article}
\usepackage{booktabs}
\usepackage{tabu}
\usepackage{threeparttable}

\usepackage{xpatch}
\makeatletter
\chardef\TPT@@@asteriskcatcode=\catcode`*
\catcode`*=11
\xpatchcmd{\threeparttable}
  {\TPT@hookin{tabular}}
  {\TPT@hookin{tabular}\TPT@hookin{tabu}}
  {}{}
\catcode`*=\TPT@@@asteriskcatcode
\makeatother

\begin{document}
\centering
\begin{threeparttable}
    \begin{tabu} to .4\textwidth {XX}
        a & b\tnote{*} and c                \\\toprule
        1 & {2\tnote{*}}{~and 3}            \\
        4 & 5\tnote{*}\hspace{1.5ex}and 6   \\\bottomrule
    \end{tabu}
    \begin{tablenotes}
        \footnotesize
        \item[*] The table note.
    \end{tablenotes}
\end{threeparttable}
\end{document}

(*) That's possible thanks to a patch by @egreg.

dgs
  • 2,741

1 Answers1

12

threeparttable defines \tnote so that the symbol it typesets doesn't contribute to the cell's width, and that's the meaning of \TPToverlap.

I suggest to leave \tnote as it is (for notes appearing at the end of a cell's text) and to define

\newcommand{\mtnote}[1]{\textsuperscript{\TPTtagStyle{#1}}}

for "middle notes".

egreg
  • 1,121,712