2

I want to modify the font size of tnotes in threeparttables based on this approach of user egreg.

Minimum Working Example (MWE) of functional approach:

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

\appto\TPTnoteSettings{\footnotesize}% <-- decreases font size of tnote

\begin{document}
    \begin{table}
        \begin{threeparttable}[b]
            \caption{A caption}
            \begin{tabular}{llll}
                \toprule
                Test\tnote{1} & some & text & to have room\\
                \bottomrule
            \end{tabular}
            \begin{tablenotes}
                \item [1] the first tnote
            \end{tablenotes}
        \end{threeparttable}
    \end{table}
\end{document}

This solution works completely fine as long as I do NOT add flushleft into the preamble config of threeparttable. As soon as I add this additional config, the upper solution does not work anymore.


Minimum Working Example (MWE) of non-functional approach:

\documentclass{article}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}% <-- added `para` and `flushleft`
\usepackage{etoolbox}

\appto\TPTnoteSettings{\footnotesize}% <-- decreases font size of tnote

\begin{document}
    \begin{table}
        \begin{threeparttable}[b]
            \caption{A caption}
            \begin{tabular}{llll}
                \toprule
                Test\tnote{1} & some & text & to have room\\
                \bottomrule
            \end{tabular}
            \begin{tablenotes}
                \item [1] the first tnote
            \end{tablenotes}
        \end{threeparttable}
    \end{table}
\end{document}

Any ideas on how to solve this?

6
  • 1
    Why not just write \footnotesize right before \begin{tablenotes}?
    – Mico
    Commented Sep 22, 2020 at 13:05
  • 1
    Then how about executing \AtBeginEnvironment{tablenotes}{\footnotesize} in the preamble?
    – Mico
    Commented Sep 22, 2020 at 13:11
  • 2
    The problem is how the flushleft option is defined, it has a setup macro which when executed overwrites what ever is in \TPTnoteSettings instead of adding to it.
    – daleif
    Commented Sep 22, 2020 at 13:24
  • 1
    @Mico: Awesome, thank you! Why not posting this as an answer? :-)
    – Dave
    Commented Sep 22, 2020 at 13:26
  • 1
    Micos solution is much simpler, as otherwise you'll need to patch like this: \makeatletter \patchcmd{\TPT@opt@flushleft}{\def\TPTnoteSettings{\labelsep.2em \leftmargin\z@ \labelwidth\z@}}{\def\TPTnoteSettings{\labelsep.2em \leftmargin\z@ \labelwidth\z@\tiny}}{}{\NOPE} \makeatother which is horrible.
    – daleif
    Commented Sep 22, 2020 at 13:34

2 Answers 2

3

You can add \footnotesize to another macro:

\documentclass{article}
\usepackage{booktabs}
\usepackage[flushleft]{threeparttable}
\usepackage{etoolbox}

\appto\TPTdoTablenotes{\footnotesize}

\begin{document}

\begin{table}

\begin{threeparttable}[b]
  \caption{A caption}

  \begin{tabular}{llll}
  \toprule
  Test\tnote{1} & some & text & to have room\\
  \bottomrule
  \end{tabular}
  \begin{tablenotes}
  \item [1] the first tnote long enough to see at least a line break
  \end{tablenotes}
\end{threeparttable}

\end{table}

\end{document}

enter image description here

2
  • Just out of curiosity: Other than demonstrating advanced knowledge about the inner workings of the threeparttable package, are there practical advantages to running \appto\TPTdoTablenotes{\footnotesize} instead of \AtBeginEnvironment{tablenotes}{\footnotesize}?
    – Mico
    Commented Sep 22, 2020 at 14:21
  • 1
    @Mico I happen to not like \AtBeginEnvironment… ;-)
    – egreg
    Commented Sep 22, 2020 at 14:37
3

Your formatting objective may be achieved robustly by running

\usepackage{etoolbox}
\AtBeginEnvironment{tablenotes}{\footnotesize}

in the preamble.

A full MWE -- note that it runs both \smallskip and \footnotesize at the start of each tablenotes environment:

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage[flushleft,para]{threeparttable}

\usepackage{etoolbox}
\AtBeginEnvironment{tablenotes}{\smallskip\footnotesize}

\begin{document}
    \begin{table}
    \centering
    \begin{threeparttable}
        \caption{A caption}
        \begin{tabular}{llll}
        \toprule
        Test\tnote{1} & some & text & to have room\\
        \bottomrule
        \end{tabular}
        \begin{tablenotes}
        \item[1] The first tnote
        \end{tablenotes}
    \end{threeparttable}
    \end{table}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .