[Tex/LaTex] Table notes in threeparttable misaligned

threeparttable

Very new to this. Have written something like this:

\begin{threeparttable}

..... table contents....


\end{tabular}
   \begin{tablenotes}[flushleft]
     \small
\item table comment 1
\item table comment 2
\item blah blah comment 3
   \end{tablenotes}
 \end{threeparttable}

I wanted the notes to be flush left against the left edge of table, which it has done, but it is misagligned – there is a space before the first character of the first line of each note, the second line is aligned further left.

So looks like this:

    table comment 1..........

 table 1 comment continued (spans two lines)

    table comment 2

I want the notes to line up left in a straight line.

Also, anyway to put a small space between the notes? Thanks for any help!

Best Answer

\item[<marker>] without the optional marker argument uses an empty marker as default. The marker is put into \tnote, more or less a wrapper for \textsuperscript (an empty superscript in math mode). Then \item appends the space \labelsep.

In short we have: $^{}$\kern\labelsep

The first adds space \scriptspace (see "The TeXbook", "Appendix G. Generating Boxes from formulas", rule 18c). The amount is 0.5 pt. \labelsep is 0.2em or about 2 pt. Thus the overall space is about 2.5 pt.

The space can therefore be removed by:

\item
  \leavevmode
  \kern-\scriptspace
  \kern-\labelsep

The following example also adds some vertical space between the notes, by patching \TPTdoTablenotes:

\documentclass{article}
\usepackage{threeparttable}
\usepackage{etoolbox}

\makeatletter
\patchcmd\TPTdoTablenotes{%
  \TPTnoteSettings
}{%
  \TPTnoteSettings
  \setlength{\itemsep}{2ex}%
}{}{\errmessage{Patching \noexpand\TPTdoTablenotes failed}}
\makeatother

\begin{document}
\begin{threeparttable}
\begin{tabular}{ll}
1&a\tnote{a}\\2&b\tnote{b}\\3&c\\
\hline
\end{tabular}
\begin{tablenotes}[flushleft]
\small
\item[a] table comment~1
\item[b] table comment~2
\item \leavevmode\kern-\scriptspace\kern-\labelsep table comment~3
\end{tablenotes}
\end{threeparttable}
\end{document}

Result