我通过 Python (pandas 数据库) 创建了一些表格输出。但是,它在第 2、3 列之间留出了太宽的空间 (我无法检测出原因),实际上溢出了页面宽度。
示例代码如下
% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = pdflatexmk
\documentclass[11pt]{article}
\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper} % ... or a4paper or a5paper or ...
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\begin{longtable}{lrrrrrrrrrrrrrr}
\toprule
{} & $\underline Y$ & $\bar Y $ & $\epsilon$ & $\bar p$ & $\underline s$ & $\bar s$ & $\theta$ & $\underline\theta$ & $\bar\theta$ & u & $\underline v$ & $\bar v$ & $\underline w$ & $\bar w$ \\
\midrule
\endhead
\midrule
\multicolumn{3}{r}{{Continued on next page}} \\
\midrule
\endfoot
\bottomrule
\endlastfoot
0 & 0.532 & 0.394 & 1.0 & 1.349 & 0.20 & 0.40 & 32.223 & 12.978 & 19.245 & 0.074 & 0.960 & 1.424 & 0.423 & 0.458 \\
1 & 0.603 & 0.317 & 1.0 & 1.901 & 0.15 & 0.65 & 38.459 & 11.728 & 26.731 & 0.079 & 0.928 & 2.115 & 0.485 & 0.576 \\
2 & 0.566 & 0.361 & 0.5 & 1.253 & 0.20 & 0.40 & 30.642 & 13.475 & 17.167 & 0.073 & 0.986 & 1.256 & 0.407 & 0.433 \\
3 & 0.504 & 0.422 & 2.0 & 1.428 & 0.20 & 0.40 & 33.573 & 12.558 & 21.015 & 0.075 & 0.937 & 1.568 & 0.437 & 0.479 \\
\end{longtable}
\end{document}
答案1
由于您的表有十五 [15!] 列,因此减少\tabcolsep
控制列间空白量的参数的值是有帮助的。
在下面的示例中,插入表格上方的细线只是为了说明文本块的宽度。
\documentclass[11pt]{article}
\usepackage{geometry}
\geometry{letterpaper,margin=1in}
\usepackage{booktabs,longtable}
\begin{document}
{\setlength\tabcolsep{3.5pt} % default value: 6pt
\begin{longtable}{@{} l *{14}{r} @{}}
\toprule
& $\underline Y$ & $\bar Y $ & $\epsilon$ & $\bar p$ & $\underline s$ & $\bar s$ & $\theta$ & $\underline\theta$ & $\bar\theta$ & u & $\underline v$ & $\bar v$ & $\underline w$ & $\bar w$ \\
\midrule
\endhead
\midrule
\multicolumn{15}{r}{Continued on next page} \\
\endfoot
\bottomrule
\endlastfoot
0 & 0.532 & 0.394 & 1.0 & 1.349 & 0.20 & 0.40 & 32.223 & 12.978 & 19.245 & 0.074 & 0.960 & 1.424 & 0.423 & 0.458 \\
1 & 0.603 & 0.317 & 1.0 & 1.901 & 0.15 & 0.65 & 38.459 & 11.728 & 26.731 & 0.079 & 0.928 & 2.115 & 0.485 & 0.576 \\
2 & 0.566 & 0.361 & 0.5 & 1.253 & 0.20 & 0.40 & 30.642 & 13.475 & 17.167 & 0.073 & 0.986 & 1.256 & 0.407 & 0.433 \\
3 & 0.504 & 0.422 & 2.0 & 1.428 & 0.20 & 0.40 & 33.573 & 12.558 & 21.015 & 0.075 & 0.937 & 1.568 & 0.437 & 0.479 \\
\end{longtable}
} % end of scope of "\setlength\tabcolsep{3.5pt} "
\end{document}
答案2
首先要抑制白色,因为Continued on next page
文本是右对齐的,所以必须使用\multicolumn{total number of columns}
。
解决这个问题后,您可以使用landscape
环境并保留默认间距参数,或者减少tabcolsep
和/或font size
。以下是显示两种结果的代码。
我还用借用字体(未加载包,因为它会干扰默认的数学字体)的字体替换了\bar
重音符号(对于大写字母来说太小) 。\widebar
mathabx
\documentclass[11pt]{article}
\usepackage{geometry} % See geometry.pdf to learn the layout options. There are lots.
\geometry{letterpaper, showframe, nomarginpar} % ... or a4paper or a5paper or ...%
\usepackage{lscape}
\usepackage{array, booktabs}
\usepackage{longtable}
\DeclareFontFamily{U}{mathx}{\hyphenchar\font45}
\DeclareFontShape{U}{mathx}{m}{n}{
<-6> mathx5 <6-7> mathx6 <7-8> mathx7
<8-9> mathx8 <9-10> mathx9
<10-12> mathx10 <12-> mathx12
}{}
\DeclareSymbolFont{mathx}{U}{mathx}{m}{n}
\DeclareFontSubstitution{U}{mathx}{m}{n}
\DeclareMathAccent{\widebar}{0}{mathx}{"73}
\begin{document}
{\setlength\tabcolsep{3.7pt}\small
\begin{longtable}{l*{14}{r}}
\toprule
{} & $ \underline {Y\!}$ & $ \widebar Y $ & $\epsilon$ & $\widebar p$ & $\underline s$ & $\widebar s$ & $ θ $ & $\underline θ $ & $\widebar\theta$ & u & $\underline v$ & $\widebar v$ & $\underline w$ & $\widebar w$ \\
\midrule
\endhead
\midrule
\multicolumn{15}{r}{{Continued on next page}} \\
\midrule
\endfoot
\bottomrule
\endlastfoot
0 & 0.532 & 0.394 & 1.0 & 1.349 & 0.20 & 0.40 & 32.223 & 12.978 & 19.245 & 0.074 & 0.960 & 1.424 & 0.423 & 0.458 \\
1 & 0.603 & 0.317 & 1.0 & 1.901 & 0.15 & 0.65 & 38.459 & 11.728 & 26.731 & 0.079 & 0.928 & 2.115 & 0.485 & 0.576 \\
2 & 0.566 & 0.361 & 0.5 & 1.253 & 0.20 & 0.40 & 30.642 & 13.475 & 17.167 & 0.073 & 0.986 & 1.256 & 0.407 & 0.433 \\
3 & 0.504 & 0.422 & 2.0 & 1.428 & 0.20 & 0.40 & 33.573 & 12.558 & 21.015 & 0.075 & 0.937 & 1.568 & 0.437 & 0.479 \\
\end{longtable}
}
\clearpage
\newgeometry{showframe = false}
\begin{landscape}
\begin{longtable}{l*{14}{r}}
\toprule
{} & $ \underline {Y\!}$ & $ \widebar Y $ & $\epsilon$ & $\widebar p$ & $\underline s$ & $\widebar s$ & $ θ $ & $\underline θ $ & $\widebar\theta$ & u & $\underline v$ & $\widebar v$ & $\underline w$ & $\widebar w$ \\
\midrule
\endhead
\midrule
\multicolumn{15}{r}{{Continued on next page}} \\
\midrule
\endfoot
\bottomrule
\endlastfoot
0 & 0.532 & 0.394 & 1.0 & 1.349 & 0.20 & 0.40 & 32.223 & 12.978 & 19.245 & 0.074 & 0.960 & 1.424 & 0.423 & 0.458 \\
1 & 0.603 & 0.317 & 1.0 & 1.901 & 0.15 & 0.65 & 38.459 & 11.728 & 26.731 & 0.079 & 0.928 & 2.115 & 0.485 & 0.576 \\
2 & 0.566 & 0.361 & 0.5 & 1.253 & 0.20 & 0.40 & 30.642 & 13.475 & 17.167 & 0.073 & 0.986 & 1.256 & 0.407 & 0.433 \\
3 & 0.504 & 0.422 & 2.0 & 1.428 & 0.20 & 0.40 & 33.573 & 12.558 & 21.015 & 0.075 & 0.937 & 1.568 & 0.437 & 0.479 \\
\end{longtable}
\end{landscape}
\end{document}