[Tex/LaTex] Footnotes or sidenotes in tables with tufte-latex

footnotespackagestufte

It might be extremely simple to solve my problem, but I can't figure it out… I use the tufte-book class and I have a table inside it. In the documentation of the tufte-book class it is written that:

Any \footnotes will automatically be converted to sidenotes.

So, I tied to attach a footnote (NOT a tablenote!), which would amount to a sidenote, to one entry, but the tablefootnote package is no use, I get the error:

No counter 'Hfootnote' defined. \end{table}

This suggests that the hack with \footnotemark and manually setting the counter would not work either. Needless to say that the \sidenote command does not work either. Neither does tabularx.

My code with \sidenote does not compile at all (Minimal Non-Working Example that is…):

\documentclass{tufte-book}%

\usepackage{amsmath}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{graphicx}%

\begin{document}

\begin{table}[htb]
    \centering
    \caption{Principal elementary particles}
        \begin{tabular}{c||c|c|c|c} \hline
             & electron & proton & neutron & photon \\ \hline \hline
            symbol & e$^-$ ($\beta^-$) & p$^+$ (H$^+$) & n$^0$ & $\gamma$ \\ \hline
            el. charge [C] & $-1.602176487 \times 10^{-19}$ & $1.602176487 \times 10^{-19}$ & $0$ & $0$ \\ \hline
            mass\sidenote{at stand-sill} [kg] & $9.10938215 \times 10^{-31}$ & $1.672621637 \times 10^{-27}$ & $1.67492729 \times 10^{-27}$ & $0$ \\ \hline
        \end{tabular}
    \label{tab:PrincipalElementaryParticles}
\end{table}

\end{document}

Best Answer

The expected behavior can be achieved with using \footnotemark and footnotetext similar to other classes.

MWE:

\documentclass{tufte-book}

\usepackage{amsmath}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{graphicx}%

\begin{document}
First sidenote.\sidenote{a}

\begin{table}[htb]
    \centering
    \caption{Principal elementary particles}
        \begin{tabular}{c||c|c|c|c} \hline
             & electron & proton & neutron & photon \\ \hline \hline
            symbol & e$^-$ ($\beta^-$) & p$^+$ (H$^+$) & n$^0$ & $\gamma$ \\ \hline
            el. charge [C] & $-1.60 \times 10^{-19}$ & $1.60 \times 10^{-19}$ & $0$ & $0$ \\ \hline
            mass\footnotemark{} [kg] & $9.1 \times 10^{-31}$ & $1.67 \times 10^{-27}$ & $1.6 \times 10^{-27}$ & $0$ \\ \hline
        \end{tabular}
    \label{tab:PrincipalElementaryParticles}
\end{table}
\footnotetext{b}
Third sidenote.\sidenote{c}

\end{document}

Please note that \footnotemark [kg] leads to an error, because [kg] is taken as the optional argument to \footnotemark. I made the table a little smaller to avoid an overfull hbox.

The output is enter image description here

To preserve the possibility of adding vertical offset (as with \sidenote), a workaround is to replace \footnotetext{b} with \makeatletter \@footnotetext[-15pt]{b} \makeatother.