![pdf 页面不够大,无法容纳所有列](https://linux22.com/image/473544/pdf%20%E9%A1%B5%E9%9D%A2%E4%B8%8D%E5%A4%9F%E5%A4%A7%EF%BC%8C%E6%97%A0%E6%B3%95%E5%AE%B9%E7%BA%B3%E6%89%80%E6%9C%89%E5%88%97.png)
运行以下代码,我得到一个如下图所示的表格,其中标题 3 的最后一个元素不适合 PDF 工作表空间,并且其元素丢失。我如何确保最后一列也适合 PDF 工作表?
这是代码:
\documentclass{article}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{geometry}
% Set smaller margins for more space
\geometry{margin=1cm}
\begin{document}
\begin{table}
\small % Reduce font size
\begin{tabular}{*{13}{S}}
\toprule
& \multicolumn{3}{c}{\textbf{Headline 1}} & \multicolumn{4}{c}{\textbf{Headline 2}} & \multicolumn{5}{c}{\textbf{Headline 3}} \\ \cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(lr){10-13}
{$\alpha$} & {$F$} & {$T_n$} & {$B_n$} & {$\bar{B}_n$} &{$F$} & {$T_n$} & {$B_n$} & {$\bar{B}_n$} & {$F$} & {$T_n$} & {$B_n$} & {$\bar{B}_n$} \\ % Corrected column entry here
\midrule
& 16.128 & +8.872 & 16.128 & 1.402 & 1.373 & -146.6 & -137.6 & -137.6 & 1.373 & -146.6 & -137.6 & -17.6 \\
0.99 & 3.442 & -2.509 & 3.442 & 0.299 & 0.343 & 133.2 & 152.4 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
& 0. & -0.429 & 0.993 & 0.086 & 0.08 & 25.6 & 90 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
\midrule
& 0.483 & -0.183 & 0.483 & 0.042 & 0.063 & 22.3 & 122.5 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
0.95 & 0.766 & -0.475 & 0.766 & 0.067 & 0.039 & 141.6 & -122 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
& 0.624 & +0.365 & 0.624 & 0.054 & 0.04 & -35.7 & 90 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
\midrule
& 0.766 & -0.475 & 0.766 & 0.067 & 0.039 & 141.6 & -122 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
0.90 & 0.45 & +0.421 & 0.45 & 0.039 & 0.034 & -69.4 & 110.9 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
& 0.598 & -0.597 & 0.598 & 0.052 & 0.025 & 92.3 & -109.3 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
如果为每一列定义合适的表格格式,则可以节省大量空间S
:
\documentclass{article}
\usepackage{amsfonts}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{geometry}
% Set smaller margins for more space
\geometry{margin=1cm}
\begin{document}
\begin{table}
\centering
\small % Reduce font size
\begin{tabular}{
S[table-format=1.2]
S[table-format=2.3]
S[table-format=-1.3]
S[table-format=2.3]
S[table-format=1.3]
S[table-format=1.3]
S[table-format=-3.1]
S[table-format=-3.1]
S[table-format=-3.1]
S[table-format=1.3]
S[table-format=-3.1]
S[table-format=-3.1]
S[table-format=-3.1]
}
\toprule
& \multicolumn{4}{c}{\textbf{Headline 1}} & \multicolumn{4}{c}{\textbf{Headline 2}} & \multicolumn{4}{c}{\textbf{Headline 3}} \\ \cmidrule(lr){2-5} \cmidrule(lr){6-9} \cmidrule(lr){10-13}
{$\alpha$} & {$F$} & {$T_n$} & {$B_n$} & {$\bar{B}_n$} &{$F$} & {$T_n$} & {$B_n$} & {$\bar{B}_n$} & {$F$} & {$T_n$} & {$B_n$} & {$\bar{B}_n$} \\ % Corrected column entry here
\midrule
& 16.128 & +8.872 & 16.128 & 1.402 & 1.373 & -146.6 & -137.6 & -137.6 & 1.373 & -146.6 & -137.6 & -17.6 \\
0.99 & 3.442 & -2.509 & 3.442 & 0.299 & 0.343 & 133.2 & 152.4 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
& 0. & -0.429 & 0.993 & 0.086 & 0.08 & 25.6 & 90 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
\midrule
& 0.483 & -0.183 & 0.483 & 0.042 & 0.063 & 22.3 & 122.5 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
0.95 & 0.766 & -0.475 & 0.766 & 0.067 & 0.039 & 141.6 & -122 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
& 0.624 & +0.365 & 0.624 & 0.054 & 0.04 & -35.7 & 90 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
\midrule
& 0.766 & -0.475 & 0.766 & 0.067 & 0.039 & 141.6 & -122 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
0.90 & 0.45 & +0.421 & 0.45 & 0.039 & 0.034 & -69.4 & 110.9 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
& 0.598 & -0.597 & 0.598 & 0.052 & 0.025 & 92.3 & -109.3 & -137.6 & 1.373 & -146.6 & -137.6 & -137.6 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}