如何通过改变字体大小来使表格适合页面宽度?

如何通过改变字体大小来使表格适合页面宽度?
\begin{table}[htbp]
\scriptsize
\centering
\caption{Table}
\begin{tabular}{ccccccccccccccccccccc}
\toprule
\multirow{2}{*}{Status} & \multicolumn{2}{c}{Jan} & \multicolumn{2}{c}{Feb} & \multicolumn{2}{c}{Mar} & \multicolumn{2}{c}{Apr} & \multicolumn{2}{c}{Jun} & \multicolumn{2}{c}{Jul} & \multicolumn{2}{c}{Aug} & \multicolumn{2}{c}{Sep} & \multicolumn{2}{c}{Oct} \\
\cmidrule(r){2-3}\cmidrule(r){4-5}\cmidrule(r){6-7}\cmidrule(r){8-9}\cmidrule(r){10-11}\cmidrule(r){12-13}\cmidrule(r){14-15}\cmidrule(r){16-17}\cmidrule(r){18-19}\cmidrule(r){20-21}
& CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) \\
\midrule
    A & 3516  & 14.88 & 2270  & 14.17 & 2605  & 15.40 & 3668  & 15.53 & 3277  & 15.21 & 2917  & 15.30 & 4444  & 14.40 & 3321  & 13.87 & 2704  & 14.41 & 4441  & 0.13376 \\
    A & 1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 7     & 0.03 & 11    & 0.06 & 38    & 0.12 & 30    & 0.13 & 325   & 1.73 & 5056  & 0.15228 \\
    A & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 1     & 0.01 & 7     & 0.02 & 8     & 0.03 & 1     & 0.01 & 8     & 0.00024 \\
    A & 20115 & 85.12 & 13753 & 85.83 & 14306 & 84.58 & 19947 & 84.45 & 18245 & 84.71 & 16116 & 84.54 & 26301 & 85.21 & 20465 & 85.49 & 15569 & 82.96 & 23233 & 0.69975 \\
    A & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 4     & 0.02 & 5     & 0.02 & 6     & 0.03 & 20    & 0.11 & 148   & 0.00446 \\
    A & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 3     & 0.01 & 1     & 0.01 & 4     & 0.01 & 9     & 0.04 & 30    & 0.16 & 73    & 0.0022 \\
    A & 0     & 0.00 & 0     & 0.00 & 3     & 0.02 & 4     & 0.02 & 7     & 0.03 & 14    & 0.07 & 67    & 0.22 & 100   & 0.42 & 118   & 0.63 & 243   & 0.00732 \\
\bottomrule
\end{tabular}%
\end{table}%

答案1

我的建议是不要将字体大小调小到难以阅读,而是在下一行继续表格:

\documentclass{article}

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tabularx}

\begin{document}

\begin{table}[htbp]
%\small
\centering
\caption{Table}
\begin{tabularx}{\linewidth}{@{}XXXXXXXXX@{}}
\toprule
\multirow{2}{*}{Status} & \multicolumn{2}{c}{Jan} & \multicolumn{2}{c}{Feb} & \multicolumn{2}{c}{Mar} & \multicolumn{2}{c}{Apr}\\ \cmidrule(r){2-3}\cmidrule(r){4-5}\cmidrule(r){6-7}\cmidrule(r){8-9}
& CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) \\
\midrule
  A & 3516  & 14.88 & 2270  & 14.17 & 2605  & 15.40 & 3668  & 15.53\\
  A & 1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 \\
  A & 1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 \\
    A & 1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 \\
    A & 1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 \\
    A & 1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 \\    
\bottomrule
\end{tabularx}%

\bigskip
\begin{tabularx}{\linewidth}{@{}XXXXXXXXXX@{}}
\toprule
\multicolumn{2}{c}{Mai} & \multicolumn{2}{c}{Jun} & \multicolumn{2}{c}{Jul} & \multicolumn{2}{c}{Aug} & \multicolumn{2}{c}{Sep}\\ \cmidrule(r){1-2}\cmidrule(r){3-4}\cmidrule(r){5-6}\cmidrule(r){7-8}\cmidrule(r){9-10}
CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%)\\
\midrule
3516  & 14.88 & 2270  & 14.17 & 2605  & 15.40 & 3668  & 15.53& 3668  & 15.53\\
1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00\\
1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00\\
1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00\\
1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00\\
\bottomrule
\end{tabularx}%
\end{table}%

\end{document}

在此处输入图片描述

答案2

\begin{table}[htbp]
\scriptsize
\centering
\caption{Table}
\resizebox{\columnwidth}{!}{
\begin{adjustbox}{angle=55}
\begin{tabular}{ccccccccccccccccccccc}
\toprule
\multirow{2}{*}{Status} & \multicolumn{2}{c}{Jan} & \multicolumn{2}{c}{Feb} & \multicolumn{2}{c}{Mar} & \multicolumn{2}{c}{Apr} & \multicolumn{2}{c}{Jun} & \multicolumn{2}{c}{Jul} & \multicolumn{2}{c}{Aug} & \multicolumn{2}{c}{Sep} & \multicolumn{2}{c}{Oct} \\
\cmidrule(r){2-3}\cmidrule(r){4-5}\cmidrule(r){6-7}\cmidrule(r){8-9}\cmidrule(r){10-11}\cmidrule(r){12-13}\cmidrule(r){14-15}\cmidrule(r){16-17}\cmidrule(r){18-19}\cmidrule(r){20-21}
& CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) & CNT & PCT (\%) \\
\midrule
    A & 3516  & 14.88 & 2270  & 14.17 & 2605  & 15.40 & 3668  & 15.53 & 3277  & 15.21 & 2917  & 15.30 & 4444  & 14.40 & 3321  & 13.87 & 2704  & 14.41 & 4441  & 0.13376 \\
    A & 1     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 7     & 0.03 & 11    & 0.06 & 38    & 0.12 & 30    & 0.13 & 325   & 1.73 & 5056  & 0.15228 \\
    A & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 1     & 0.01 & 7     & 0.02 & 8     & 0.03 & 1     & 0.01 & 8     & 0.00024 \\
    A & 20115 & 85.12 & 13753 & 85.83 & 14306 & 84.58 & 19947 & 84.45 & 18245 & 84.71 & 16116 & 84.54 & 26301 & 85.21 & 20465 & 85.49 & 15569 & 82.96 & 23233 & 0.69975 \\
    A & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 4     & 0.02 & 5     & 0.02 & 6     & 0.03 & 20    & 0.11 & 148   & 0.00446 \\
    A & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 0     & 0.00 & 3     & 0.01 & 1     & 0.01 & 4     & 0.01 & 9     & 0.04 & 30    & 0.16 & 73    & 0.0022 \\
    A & 0     & 0.00 & 0     & 0.00 & 3     & 0.02 & 4     & 0.02 & 7     & 0.03 & 14    & 0.07 & 67    & 0.22 & 100   & 0.42 & 118   & 0.63 & 243   & 0.00732 \\
\bottomrule
\end{tabular}%
\end{adjustbox}}
\end{table}

您可以使用\resizebox{<width>}{<height>}图形包调整其大小。 \usepackage{adjustbox}用于旋转表格

相关内容