使用包 {threeparttable} 时调整表格大小

使用包 {threeparttable} 时调整表格大小

我使用这个{threeparttable}包是因为我想使用表格注释,但我在调整表格大小时遇到​​了问题。如果我使用{adjustbox}来括起来{tabular}(或{tabularx}),我会收到一条错误消息:

! You can't use `\hrule' here except with leaders. \caption@hrule
->\hrule 
                    \@height \z@  l.23 \end{tabular}}

如果我在代码的同一位置使用\resizebox或,则同样适用。\scalebox

如果我使用{adjustbox}并括起来{threeparttable},代码可以运行,但标题和表格注释的字体大小也会缩小......

在此处输入图片描述

...这不是我想要的!

有谁知道仅在使用包时调整表格字体大小的方法吗{threeparttable}

\documentclass[a4paper,14pt]{scrreprt}

\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{threeparttable}
\usepackage[labelfont=bf]{caption}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[a4paper, bindingoffset=0.5cm, tmargin=2.4cm, bmargin=3.4cm, lmargin=3.5cm, rmargin=2.5cm, footskip=2.4cm]{geometry}

\begin{document}
This is some text which refers to Table~\ref{tab:Table}
\begin{table}
\centering
% \begin{adjustbox}{max width=\textwidth}
\begin{threeparttable}
\caption{Table caption.}
\label{tab:Table}
\begin{adjustbox}{max width=\textwidth}
\begin{tabular}{@{}l*{10}{c}@{}}
\toprule
Item & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 & Col 7 & Col 8 & Col 9 & Col 10 & Col 11 \\
\midrule
Some sort of stuff\tnote{a} & 107.5 & 5.62 & 89.1 & \num{14367.7} & 3.4 & 21.9 & 112.6 & \num{18644} & 432.4 & 17 \\
\bottomrule
\end{tabular}
\end{adjustbox}
\begin{tablenotes}
\small
\item[a] This sort of stuff is only available in winter.
\end{tablenotes}
\end{threeparttable}
% \end{adjustbox}
\end{table}
Some more text.
\end{document}

答案1

threeparttable希望看到的tabulartablenotes在外层,而不是埋在里面adjustbox

非常在决定缩放表格之前,请仔细考虑。例如,14pt 的正文非常庞大,缩放后的表格相对于文本而言会消失。

我将其缩小到 11pt,这是一个相当大的字体大小。

\documentclass[a4paper,11pt]{scrreprt}

\usepackage{graphicx}
\usepackage{adjustbox}
\usepackage{threeparttable}
\usepackage[labelfont=bf]{caption}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage[a4paper, bindingoffset=0.5cm, tmargin=2.4cm, bmargin=3.4cm, lmargin=3.5cm, rmargin=2.5cm, footskip=2.4cm]{geometry}

\begin{document}
This is some text which refers to Table~\ref{tab:Table}
\begin{table}
\centering
\caption{Table caption.}
\label{tab:Table}
\begin{adjustbox}{max width=\textwidth}
\begin{threeparttable}
\begin{tabular}{@{}l*{10}{c}@{}}
\toprule
Item & Col 2 & Col 3 & Col 4 & Col 5 & Col 6 & Col 7 & Col 8 & Col 9 & Col 10 & Col 11 \\
\midrule
Some sort of stuff\tnote{a} & 107.5 & 5.62 & 89.1 & \num{14367.7} & 3.4 & 21.9 & 112.6 & \num{18644} & 432.4 & 17 \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\small
\item[a] This sort of stuff is only available in winter.
\end{tablenotes}
\end{threeparttable}
\end{adjustbox}
\end{table}
Some more text.
\end{document}

在此处输入图片描述

我是否也要缩放标题?没办法。

相关内容