10

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.

9

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".

1
  • 3
    I see. It's not a bug, it's a feature... thanks.
    – dgs
    May 21 '12 at 5:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.