使表格注释与 `\textwidth` 一样宽,同时保留表格自身的宽度

使表格注释与 `\textwidth` 一样宽,同时保留表格自身的宽度

我使用该threeparttable包制作表格,原因如下:

  • 它使我可以方便地做表格注释,这些注释可能引用表格中的特定文本;
  • 表格中的注释间隔很紧密。

出于某种原因,我需要使表格注释与周围文本 ( \textwidth) 一样宽,同时保持表格的原始自然宽度。我无法做到这一点,因为threeparttable表格与表格注释一样宽。在 MWE 中,我必须使表格与周围文本一样宽,以使表格注释一样宽。

如何使表格注释与周围文本一样宽,\textwidth同时仍保持表格的自然宽度并且同时保留了上面描述的包的两个优点threeparttable

梅威瑟:

表格注释 MWE

\documentclass{scrartcl}

\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{lipsum}

\begin{document}
    \begin{table}
        \centering
        \footnotesize
        \caption{A Narrow Table}
        \begin{threeparttable}
            \sisetup{
                detect-mode,
                tight-spacing            = true,
                group-digits             = false,
                input-signs              = ,
                input-symbols            = ,
                input-open-uncertainty   = ,
                input-close-uncertainty  = ,
                table-align-text-pre     = false,
                round-mode               = figures,
                round-precision          = 3,
                %       round-integer-to-decimal = true,
                table-space-text-pre     = (,
                table-space-text-post    = ),
            }
            \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}l*{1}{S}}
                \toprule
                Estimator          & {My Guess}            \\
                \cmidrule{2-2}
                Dependent variable & {Lottery Result}      \\
                \midrule
                Treatment          & 53.7667               \\
                                   & (3.1877)              \\
                Constant           & 86.2173***            \\
                                   & (3.4262)              \\
                \addlinespace
                Observations       & {3578}                \\
                \midrule
                Test: 0 = 2        & {$p=0.1576$}\tnote{a} \\
                Test: 1 = 3        & {$p=0.9706$}\tnote{a} \\
                \bottomrule
            \end{tabular*}
            \begin{tablenotes}
                \item A note that does not reference anything. Significance is
                    denoted: * $p < 0.10$  ** $p < 0.05$  *** $p < 0.01$.
                \item[a] A note that references text in the table.
            \end{tablenotes}
        \end{threeparttable}
    \end{table}

Surrounding text: \lipsum[1]
\end{document}

答案1

不幸的是,你似乎必须重新定义包中的一些内部宏:添加

\makeatletter
\let\TPT@hookin\@gobble
\let\TPT@hookarg\@gobble
\makeatother

\begin{document}

PDF.png

编辑:完整代码:

\documentclass{scrartcl}

\usepackage{threeparttable}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{lipsum}

\makeatletter
\let\TPT@hookin\@gobble
\let\TPT@hookarg\@gobble
\makeatother

\begin{document}
    \begin{table}
        \centering
        \footnotesize
        \caption{A Narrow Table}
        \begin{threeparttable}
            \sisetup{
                detect-mode,
                tight-spacing            = true,
                group-digits             = false,
                input-signs              = ,
                input-symbols            = ,
                input-open-uncertainty   = ,
                input-close-uncertainty  = ,
                table-align-text-pre     = false,
                round-mode               = figures,
                round-precision          = 3,
                %       round-integer-to-decimal = true,
                table-space-text-pre     = (,
                table-space-text-post    = ),
            }
            \begin{tabular}{lS}
                \toprule
                Estimator          & {My Guess}            \\
                \cmidrule{2-2}
                Dependent variable & {Lottery Result}      \\
                \midrule
                Treatment          & 53.7667               \\
                                   & (3.1877)              \\
                Constant           & 86.2173***            \\
                                   & (3.4262)              \\
                \addlinespace
                Observations       & {3578}                \\
                \midrule
                Test: 0 = 2        & {$p=0.1576$}\tnote{a} \\
                Test: 1 = 3        & {$p=0.9706$}\tnote{a} \\
                \bottomrule
            \end{tabular}
            \begin{tablenotes}
                \item A note that does not reference anything. Significance is
                    denoted: * $p < 0.10$  ** $p < 0.05$  *** $p < 0.01$.
                \item[a] A note that references text in the table.
            \end{tablenotes}
        \end{threeparttable}
    \end{table}

Surrounding text: \lipsum[1]
\end{document}

相关内容