# Forcing table to align on values in table when there is a superscript footnote marker

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:

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.

• 3\rlap{$^\dagger$} Aug 18 at 10:12

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

\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}

• I didnt know about the threeparttable package, it looks perfect for my purposes - thanks a lot, ill look into it further.. Aug 18 at 14:50

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}


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}


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}