13

I am using threeparttable for adding notes to my table. Here is a minimal working example:

\documentclass[12pt]{memoir}

\usepackage[para,online,flushleft]{threeparttable}

\begin{document}
\par
Lets test the threeparttable package.
\begin{table}[h]
\caption{Some very informative caption}
\begin{center}
\begin{threeparttable}
\begin{tabular}{c c c c}
    \toprule
    \textbf{1st Column} & \textbf{2nd Colimn} & \textbf{3rd Colimn} & \textbf{4th Colimn} \\ \midrule
      QWERTY\tnote{1}   &                     &                     &  \\
      ASDFGH\tnote{2}   &                     &                     &  \\ \bottomrule
\end{tabular}
\begin{tablenotes}
\item[1] qwerty; \item[2] asdfgh
\end{tablenotes}
\end{threeparttable}
\end{center}
\label{table:simDisimCoefNewDef}
\end{table}
\end{document} 

which produce the following:

threeparttable

So what I need is to set minimum distance between notes on same line like in normal text. Is that possible?

8

enter image description here

The para setting in threeparttable uses an interesting collection of penalties and glue but I think you just want to change the length indicated (the default is 1em I changed it to 6em here) Unrelated but I also changed [h] to [htp] as using h on its own is asking the float to go to the end of the document.

\documentclass[12pt]{memoir}

\usepackage[para,online,flushleft]{threeparttable}

\makeatletter
\def\TPT@doparanotes{\par
   \prevdepth\z@ \TPT@hsize
   \TPTnoteSettings
   \parindent\z@ \pretolerance 8
   \linepenalty 200
   \renewcommand\item[1][]{\relax\ifhmode \begingroup
       \unskip
       \advance\hsize 10em % \hsize is scratch register, based on real hsize
       \penalty -45 \hskip\z@\@plus\hsize \penalty-19
       \hskip .15\hsize \penalty 9999 \hskip-.15\hsize
       \hskip .01\hsize\@plus-\hsize\@minus.01\hsize 
       \hskip 6em\@plus .3em
              %%%%%
      \endgroup\fi
      \tnote{##1}\,\ignorespaces}%
   \let\TPToverlap\relax
   \def\endtablenotes{\par}%
}

\makeatother
\begin{document}
\par
Lets test the threeparttable package.
\begin{table}[htp]
\caption{Some very informative caption}
\begin{center}
\begin{threeparttable}
\begin{tabular}{c c c c}
    \toprule
    \textbf{1st Column} & \textbf{2nd Colimn} & \textbf{3rd Colimn} & \textbf{4th Colimn} \\ \midrule
      QWERTY\tnote{1}   &                     &                     &  \\
      ASDFGH\tnote{2}   &                     &                     &  \\ \bottomrule
\end{tabular}
\begin{tablenotes}
\item[1] qwerty; \item[2] asdfgh
\end{tablenotes}
\end{threeparttable}
\end{center}
\label{table:simDisimCoefNewDef}
\end{table}
\end{document} 
4
  • 1
    I guess the question is how to remove the additional space and use a normal interword space (instead of 6em use 0em, of course). I'd notice also that \centering is to be used instead of center and that the \label should be nearer to the caption (just in case some \refstepcounter comes along).
    – egreg
    Jun 11 '13 at 23:00
  • It works with David code and @egreg advice. Jun 11 '13 at 23:13
  • @David Carlisle, could you please explain your code because I noticed different output in some cases, e.g. when putting \textit in \item. What are all this penalties for? Jun 12 '13 at 6:38
  • 1
    @alchemist_bg it's not my code the definition is just copied from three part table I just changed 1em to 6em I'm not sure why Donald had quite such a complicated collection, but he knows what he's doing:-) basically the idea is to allow extra flexibility between the notes and to encourage line breaking there rather than inside the note if possible. Jun 12 '13 at 7:35
1

The environment {NiceTabular} of nicematrix has a built-in command \tabularnote to compose notes after the tabular. This list of notes is composed with the tools of the package enumitem. It's possible to customize with all the keys provided by enumitem. For example, the tokens inserted between two notes (in para mode) may be set with the key itemjoin.

\documentclass[12pt]{memoir}
\usepackage{nicematrix,enumitem}

\begin{document}

\begin{table}[h]
\caption{Some very informative caption}
\centering
\NiceMatrixOptions{notes/para}
\begin{NiceTabular}{c c c c}
    \toprule
    \RowStyle{\bfseries}
    1st Column & 2nd Column & 3rd Column & 4th Column \\ \midrule
    QWERTY\tabularnote{qwerty}  & & &  \\
    ASDFGH\tabularnote{asdefgh} & & &  \\ \bottomrule
\end{NiceTabular}
\label{table:simDisimCoefNewDef}
\end{table}


\begin{table}[h]
\caption{Some very informative caption}
\centering
\NiceMatrixOptions{notes/para,notes/enumitem-keys-para={itemjoin = ;\;}}
\begin{NiceTabular}{c c c c}
    \toprule
    \RowStyle{\bfseries}
    1st Column & 2nd Column & 3rd Column & 4th Column \\ \midrule
    QWERTY\tabularnote{qwerty}  & & &  \\
    ASDFGH\tabularnote{asdefgh} & & &  \\ \bottomrule
\end{NiceTabular}
\label{table:simDisimCoefNewDef}
\end{table}

\end{document} 

Output of the above code

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.