3

I have a table with some data (right aligned), one entry of which I would like to put a note at the bottom of the table for. However, when I put a superscript marker next to the entry, it pushes the value further to the left and I lose the right alignment.

Here is a MWE:

\documentclass{article}
\usepackage{booktabs} 
\usepackage{multicol}
\begin{document}
\begin{table}
\centering
\caption{Test table}
\begin{tabular}{lrrr} \toprule
col 1 & col 2 & col 3 & col 4\\ \midrule
%
test 1 & 2 & 3$^\dagger$ & 4\\
test 2 & 6 & 7 & 8\\
%
\bottomrule
\multicolumn{4}{l}{\footnotesize$^\dagger$Some note goes here.}
\end{tabular}
\end{table}
\end{document}

Producing:

enter image description here

Is there a way to force it to line up by the values in the columns? The only way I can think of, is to put an extra column that is left aligned to put the marker, but I wanted to check if there was a better way to do it.

1

2 Answers 2

4

I'd like to suggest that you load the threeparttable package and use that package's \tnote directive and threeparttableand tablenotes environments.

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\begin{document}

\begin{table}
\centering
\begin{threeparttable}

\caption{Test table}

\begin{tabular}{@{} lccc @{}} 
\toprule
col 1 & col 2 & col 3 & col 4 \\ 
\midrule
test 1 & 2 & 3\tnote{$\dagger$} & 4 \\
test 2 & 6 & 7 & 8 \\
\bottomrule
\end{tabular}

\smallskip\footnotessize
\begin{tablenotes}
\item[$\dagger$] Some note goes here.
\end{tablenotes}

\end{threeparttable}
\end{table}

\end{document}
1
  • 1
    I didnt know about the threeparttable package, it looks perfect for my purposes - thanks a lot, ill look into it further..
    – guskenny83
    Aug 18 at 14:50
1

The package nicematrix provides an environment {NiceTabular} with its own system for tabular notes. One inserts a tabular note with the command \tabularnote as he would do for \footnote.

If a command \tabularnote{...} is exactly at the end of a cell (with no space at all after), the label of the note is composed in an overlapping position (towards the right). Here is an illustration:

\documentclass{article}
\usepackage{booktabs}
\usepackage{nicematrix}
\usepackage{enumitem}
\usepackage{caption}

\begin{document}

\NiceMatrixOptions{ notes = { code-before = \footnotesize } }

\begin{table}
\centering
\caption{Test table}

\begin{NiceTabular}{@{} lccc @{}} 
\toprule
col 1 & col 2 & col 3 & col 4 \\ 
\midrule
test 1 & 2 & 3\tabularnote{First note.} & 4 \\
test 2 & 6\tabularnote{Second Note}& 7 & 8 \\
\bottomrule
\end{NiceTabular}
\end{table}

\end{document}

Output of the first code

It's easy to change the style of numeration. For example, replacing a, b, c... by 1, 2, 3... that is to say \alph by \arabic.

\documentclass{article}
\usepackage{booktabs}
\usepackage{nicematrix}
\usepackage{enumitem}
\usepackage{caption}

\begin{document}

\NiceMatrixOptions{ notes = { code-before = \footnotesize , style = \arabic{#1} } }

\begin{table}
\centering
\caption{Test table}

\begin{NiceTabular}{@{} lccc @{}} 
\toprule
col 1 & col 2 & col 3 & col 4 \\ 
\midrule
test 1 & 2 & 3\tabularnote{First note.} & 4 \\
test 2 & 6\tabularnote{Second Note}& 7 & 8 \\
\bottomrule
\end{NiceTabular}
\end{table}

\end{document}

Output of the second code

However, replacing a, b, c... by †, ‡, ¶... is a bit more complicated:

\documentclass{article}
\usepackage{booktabs}
\usepackage{nicematrix}
\usepackage{enumitem}
\usepackage{caption}
\usepackage{ifthen}

\begin{document}


\NewDocumentCommand{\Symbol}{m}
  {
    \ifthenelse{\value{#1}=0}
      {\relax}
      {\ifthenelse{\value{#1}=1}
         {$\dagger$}
         {\ifthenelse{\value{#1}=2}
            {$\ddagger$}
            {\ifthenselse{\value{#1}=3}
               {\P}
               {}}}}}

\NiceMatrixOptions { notes = { code-before = \footnotesize , style = \Symbol{#1} } }

\begin{table}
\centering
\caption{Test table}

\begin{NiceTabular}{@{} lccc @{}} 
\toprule
col 1 & col 2 & col 3 & col 4 \\ 
\midrule
test 1 & 2 & 3\tabularnote{First note.} & 4 \\
test 2 & 6\tabularnote{Second Note}& 7 & 8 \\
\bottomrule
\end{NiceTabular}
\end{table}

\end{document}

Output of the third 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.