2

I use the threeparttable package to make tables, for the following reasons:

  • It allows me to conveniently make table notes that may refer to specific text in the table;
  • The table notes are tightly spaced.

For some reason, I need to make the table notes as wide as the surrounding text (\textwidth) while keeping the table its original, natural width. I have not been able to do this since in threeparttable the table are as wide as the table notes. In the MWE, I had to make the table as wide as the surrounding text to make the table notes as wide.

How do I make the table notes as wide as the surrounding text \textwidth while still keeping the table its natural width and while retaining the two nice features of the threeparttable package describe above?

MWE:

table notes 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}
3

Unfortunately it seems that you have to redefine some internal macro of the package: add

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

before \begin{document}.

PDF.png

EDIT: Complete code:

\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}
  • I added the macro but am not seeing the result in your screenshot. Could you please include the complete code? – Fang Jing Jan 9 at 16:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.