Threeparttable:在使用flushleft 時如何更改 Threeparttable 表格註解的字體大小?

Threeparttable:在使用flushleft 時如何更改 Threeparttable 表格註解的字體大小?

我想根據以下內容修改tnotesin的字體大小threeparttables使用者egreg的這種方法

函數式方法的最小工作範例(MWE):

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

只要我不flushleft加到threeparttable.一旦我添加了這個額外的配置,上面的解決方案就不再起作用了。


非功能性方法的最小工作範例(MWE):

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

關於如何解決這個問題有什麼想法嗎?

答案1

您可以新增\footnotesize到另一個巨集:

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

在此輸入影像描述

答案2

透過運行可以穩健地實現您的格式化目標

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

在序言中。

完整的 MWE - 請注意,它在每個環境的開始時都運行\smallskip和:\footnotesizetablenotes

在此輸入影像描述

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

相關內容