我的表格太宽,页面放不下。如何更改表格中的字体大小?
这是源代码。
\documentclass[12pt]{article}
\usepackage{booktabs}
\usepackage{multirow}
\begin{document}
\begin{table*}[ht]
\caption{Dissemination Time and Success in ONE Simulation}
%\vspace{-.25cm}
\centering
\begin{tabular}{l ccc c ccc c ccc c ccc}
\toprule
& \multicolumn{7}{c}{1K/2K byte budget} && \multicolumn{7}{c}{5K byte budget}\\
\cmidrule{2-8} \cmidrule{10-16}
& \multicolumn{3}{c}{success (\%)} && \multicolumn{3}{c}{time (s)} &&\multicolumn{3}{c}{success (\%)} && \multicolumn{3}{c}{time (s)} \\
\addlinespace
& FBF & Labeled & JSON && FBF & Labeled & JSON && FBF & Labeled & JSON && FBF & Labeled & JSON\\
\midrule
{\em Manhattan} & 100\% & 67\% & 67\% && 1248 & 1820 & 2446 && 100\% & 100\% & 100\% && 675 & 583 & 1485\\
{\em mini-Manhattan} & 27\% & 11\% & 16\% && 329 & 315 & 208 && 78\% & 53\% & 33\% && 263 & 364 & 308\\
\bottomrule
\end{tabular}
\label{table:dissemination}
\vspace{-.25cm}
\end{table*}
\end{document}
答案1
如果 (a) 设置合理的页边距(例如,1 英寸宽),(b) 将相对字体大小设置为\footnotesize
(从 线性减少 20% \normalsize
),(c) 删除三个空列,(d) 使用环境tabular*
(将宽度设置为\textwidth
),让 LaTeX 计算出可以在列之间插入的空白量,则可以使表格适合。
\documentclass[12pt]{article}
\usepackage[a4paper,margin=2.5cm]{geometry} % set page parameters
\usepackage{booktabs,caption}
\begin{document}
\begin{table}[ht]
\captionsetup{skip=0.5\baselineskip,size=footnotesize}
\footnotesize
\setlength\tabcolsep{0pt}
\caption{Dissemination Time and Success in ONE Simulation}
\label{table:dissemination}
\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} *{12}{c}}
\toprule
& \multicolumn{6}{c}{1K/2K byte budget}
& \multicolumn{6}{c}{5K byte budget}\\
\cmidrule{2-7} \cmidrule{8-13}
& \multicolumn{3}{c}{success (\%)} & \multicolumn{3}{c}{time (s)}
& \multicolumn{3}{c}{success (\%)} & \multicolumn{3}{c}{time (s)} \\
\cmidrule{2-4} \cmidrule{5-7} \cmidrule{8-10} \cmidrule{11-13}
& FBF & Labeled & JSON & FBF & Labeled & JSON
& FBF & Labeled & JSON & FBF & Labeled & JSON\\
\midrule
\em Manhattan & 100\% & 67\% & 67\% & 1248 & 1820 & 2446 & 100\% & 100\% & 100\% & 675 & 583 & 1485\\
\em mini-Manhattan & 27\% & 11\% & 16\% & 329 & 315 & 208 & 78\% & 53\% & 33\% & 263 & 364 & 308\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}