我正在设置一个大表(几百页),其中包含与所示类似的数据。我longtable
过去使用过,效果很好,没有问题。但是,当我再次尝试执行相同操作时,出现以下错误:
- 表格的标题(+ 页面底部的行)未跨越整个表格宽度。
- 表格中不同位置的列对齐方式会发生变化。
我尝试寻找解决方案,但没有任何问题。任何建议都将不胜感激。
在 ubuntu 11.10 上使用 Kile 2.1.0(KDE 4.8.2)。
以下是该表使用的代码:
\documentclass[ twoside,openright,titlepage,fleqn,numbers=noenddot,headinclude,%1headlines,% letterpaper a4paper
11pt,a4paper,BCOR5mm,footinclude=true,cleardoublepage=empty,abstractoff % <--- obsolete, remove (todo)
]{scrreprt}
\usepackage{lscape}
\usepackage{longtable}
\begin{landscape}
\begin{small}
\begin{longtable}{cccccccccccccccc}
\caption[HTML Test Table]{Table shows the problem that I am facing with the correct alignment of all columns. I do not know hat is going on and I have been working on this for quite a while now, but with no success...}\label{c0B:tab:6kvis_full}\\
\hline
\multicolumn{1}{c}{HTM Name}&
\multicolumn{1}{c}{Northing}&
\multicolumn{1}{c}{Easting}&
\multicolumn{1}{c}{Val1}&
\multicolumn{1}{c}{Val1.1}&
\multicolumn{1}{c}{Val4.8}&
\multicolumn{1}{c}{Val5.6}&
\multicolumn{1}{c}{Val9.8}&
\multicolumn{1}{c}{A}&
\multicolumn{1}{c}{B}&
\multicolumn{1}{c}{C}&
\multicolumn{1}{c}{D}&
\multicolumn{1}{c}{E}&
\multicolumn{1}{c}{F}&
\multicolumn{1}{c}{Num1}&
\multicolumn{1}{c}{Num2}\\
\cline{4 - 8}
%NextLine
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{(Northing)}&
\multicolumn{1}{c}{(Easting)}&
\multicolumn{5}{c}{(NanoSec)}&
\multicolumn{0}{c}{}&
\multicolumn{0}{c}{}&
\multicolumn{0}{c}{}&
\multicolumn{0}{c}{}&
\multicolumn{0}{c}{}&
\multicolumn{0}{c}{}&
\multicolumn{0}{c}{}&
\multicolumn{0}{c}{}\\*
\hline
\endfirsthead
\multicolumn{16}{c}{Continued Table}\\
\hline
\multicolumn{1}{c}{HTM Name}&
\multicolumn{1}{c}{Northing}&
\multicolumn{1}{c}{Easting}&
\multicolumn{1}{c}{Val1}&
\multicolumn{1}{c}{Val1.1}&
\multicolumn{1}{c}{Val4.8}&
\multicolumn{1}{c}{Val5.6}&
\multicolumn{1}{c}{Val9.8}&
\multicolumn{1}{c}{A}&
\multicolumn{1}{c}{B}&
\multicolumn{1}{c}{C}&
\multicolumn{1}{c}{D}&
\multicolumn{1}{c}{E}&
\multicolumn{1}{c}{F}&
\multicolumn{1}{c}{Num1}&
\multicolumn{1}{c}{Num2}\\
\cline{4 - 8}
%NextLine
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{(Northing)}&
\multicolumn{1}{c}{(Easting)}&
\multicolumn{5}{c}{(NanoSec)}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{}\\*
\hline
\endhead
\hline
\multicolumn{16}{c}{Continued on next page \dots}
\endfoot
\hline
\endlastfoot
%Data starts here
HTM20 M000012233919&00:00:12.78&-23:39:19.96&98&63&63&&104&-0.29&-0.22&-0.02&0.00&0.31&0.53&0.94&0.99\\
HTM20 M000020-322101&00:00:20.38&-32:21:01.23&118&315&515&521&322&-0.01&-0.28&-0.56&-0.84&-1.03&-1.17&0.97&1.06\\
HTM20 M000105-155107&00:01:05.42&-15:51:07.20&297&295&257&348&-&-0.24&-0.21&-0.06&0.23&0.10&0.01&0.93&0.97\\
HTM20 M000106-174126&00:01:06.31&-17:41:26.21&73&-&-&447&-&-&-&-0.69&-&-&-&0.85&1.14\\
HTM20 M000118-074626&00:01:18.04&-07:46:26.86&177&-&-&208&-&-&-&-0.06&-&-&-&0.91&0.99\\
HTM20 M000124-043759&00:01:24.50&-04:37:59.61&50&-&-&632&-&-&-&-0.96&-&-&-&0.42&0.56\\
HTM20 M000713-402337&00:07:13.41&-40:23:37.43&69&89&97&-&98&-0.01&-0.04&-0.11&-0.15&-0.24&-0.30&0.9&1.02\\
HTM20 M000720-611306&00:07:20.56&-61:13:06.73&150&138&134&-&86&0.26&0.20&0.18&0.05&0.08&0.10&0.97&0.98**\\
HTM20 M000800-233918&00:08:00.42&-23:39:18.04&154&-&-&374&-&-&-&-0.34&-&-&-&0.94&0.97\\
HTM20 M000801-524339&00:08:01.71&-52:43:39.90&124&127&101&-&256&-0.53&-0.30&-0.23&0.39&0.14&-0.03&0.98&1.05\\
HTM20 M000821-394522&00:08:21.18&-39:45:22.9&146&169&188&150&134&0.18&0.07&-0.01&-0.18&-0.18&-0.17&--&--\\
HTM20 M000826-255911&00:08:26.27&-25:59:11.29&120&259&360&468&-&-0.21&-0.33&-0.52&-0.56&-0.77&-0.92&0.92&0.95\\
HTM20 M000828-132930&00:08:28.02&-13:29:30.32&161&-&-&192&-&-&-&-0.07&-&-&-&0.96&--\\
HTM20 M000829-055845&00:08:29.33&-05:58:45.27&66&-&-&1322&-&-&-&-1.14&-&-&-&0.66&0.68\\
HTM20 M000831-141959&00:08:31.08&-14:19:59.93&53&-&-&604&-&-&-&-0.92&-&-&-&0.79&--\\
HTM20 M000837-461940&00:08:37.53&-46:19:40.85&75&98&95&-&114&-0.10&-0.06&-0.13&0.05&-0.17&-0.32&1.0&1.0\\
HTM20 M002122-513011&00:21:22.06&-51:30:11.9&49&59&56&-&45&0.12&0.12&0.03&0.21&-0.21&-0.22&1.11&--\\
HTM20 M002127-161028&00:21:27.55&-16:10:28.82&69&92&61&55&-&0.08&0.28&0.21&0.70&0.21&-0.34&0.95&1.01\\
HTM20 M002135-321637&00:21:35.67&-32:16:37.39&221&275&313&388&559&-0.17&-0.19&-0.21&-0.22&-0.24&-0.26&0.79&--\\
\` before the final
\hline
\end{longtable}
\end{small}
\end{landscape}
答案1
发布的代码由于多种原因无法编译,包括:(1)没有\begin{document}
和(2)表格中间有几个段落中断。
纠正这些问题后,表格196pts
对于页面来说太宽了。将字体替换为\tiny
而不是\small
(NB,没有环境small
) 会有所帮助。与其将所有列指定为居中,不如根据每列中的材料选择格式。大多数带有小数的列最好将小数对齐,该dcolumn
软件包可以帮助实现这一点。
综合起来我们得到:
\documentclass[twoside,openright,titlepage,fleqn,numbers=noenddot,headinclude,
11pt,a4paper,BCOR5mm,footinclude=true,cleardoublepage=empty,abstractoff % <--- obsolete, remove (todo)
]{scrreprt}
\usepackage{lmodern}
\usepackage{lscape}
\usepackage{longtable}
\usepackage{dcolumn}
\newcolumntype{d}{D{.}{.}{2}}
\begin{document}
\begin{landscape}
\tiny
\begin{longtable}{lllrrrrrddddddrr}
\caption[HTML Test Table]{Table shows the problem that I am facing with the correct alignment of all columns. I do not know hat is going on and I have been working on this for quite a while now, but with no success...}\label{c0B:tab:6kvis_full}\\
\hline
\multicolumn{1}{c}{HTM Name}&
\multicolumn{1}{c}{Northing}&
\multicolumn{1}{c}{Easting}&
\multicolumn{1}{c}{Val1}&
\multicolumn{1}{c}{Val1.1}&
\multicolumn{1}{c}{Val4.8}&
\multicolumn{1}{c}{Val5.6}&
\multicolumn{1}{c}{Val9.8}&
\multicolumn{1}{c}{A}&
\multicolumn{1}{c}{B}&
\multicolumn{1}{c}{C}&
\multicolumn{1}{c}{D}&
\multicolumn{1}{c}{E}&
\multicolumn{1}{c}{F}&
\multicolumn{1}{c}{Num1}&
\multicolumn{1}{c}{Num2}\\
\cline{4 - 8}
%NextLine
\multicolumn{1}{c}{}&
\multicolumn{1}{c}{(Northing)}&
\multicolumn{1}{c}{(Easting)}&
\multicolumn{5}{c}{(NanoSec)}&
&
&
&
&
&
&
&
\\*
\hline
\endfirsthead
\multicolumn{16}{c}{Continued Table}\\
\hline
HTM Name&
Northing&
Easting&
Val1&
Val1.1&
Val4.8&
Val5.6&
Val9.8&
A&
B&
C&
D&
E&
F&
Num1&
Num2\\
\cline{4 - 8}
%NextLine
&
(Northing)&
(Easting)&
\multicolumn{5}{c}{(NanoSec)}&
&
&
&
&
&
&
&
\\*
\hline
\endhead
\hline
\multicolumn{16}{c}{Continued on next page \dots}
\endfoot
\hline
\endlastfoot
%Data starts here
HTM20 M000012233919&00:00:12.78&-23:39:19.96&98&63&63&&104&-0.29&-0.22&-0.02&0.00&0.31&0.53&0.94&0.99\\
HTM20 M000020-322101&00:00:20.38&-32:21:01.23&118&315&515&521&322&-0.01&-0.28&-0.56&-0.84&-1.03&-1.17&0.97&1.06\\
HTM20 M000105-155107&00:01:05.42&-15:51:07.20&297&295&257&348&-&-0.24&-0.21&-0.06&0.23&0.10&0.01&0.93&0.97\\
HTM20 M000106-174126&00:01:06.31&-17:41:26.21&73&-&-&447&-&-&-&-0.69&-&-&-&0.85&1.14\\
HTM20 M000118-074626&00:01:18.04&-07:46:26.86&177&-&-&208&-&-&-&-0.06&-&-&-&0.91&0.99\\
HTM20 M000124-043759&00:01:24.50&-04:37:59.61&50&-&-&632&-&-&-&-0.96&-&-&-&0.42&0.56\\
HTM20 M000713-402337&00:07:13.41&-40:23:37.43&69&89&97&-&98&-0.01&-0.04&-0.11&-0.15&-0.24&-0.30&0.9&1.02\\
HTM20 M000720-611306&00:07:20.56&-61:13:06.73&150&138&134&-&86&0.26&0.20&0.18&0.05&0.08&0.10&0.97&0.98**\\
HTM20 M000800-233918&00:08:00.42&-23:39:18.04&154&-&-&374&-&-&-&-0.34&-&-&-&0.94&0.97\\
HTM20 M000801-524339&00:08:01.71&-52:43:39.90&124&127&101&-&256&-0.53&-0.30&-0.23&0.39&0.14&-0.03&0.98&1.05\\
HTM20 M000821-394522&00:08:21.18&-39:45:22.9&146&169&188&150&134&0.18&0.07&-0.01&-0.18&-0.18&-0.17&--&--\\
HTM20 M000826-255911&00:08:26.27&-25:59:11.29&120&259&360&468&-&-0.21&-0.33&-0.52&-0.56&-0.77&-0.92&0.92&0.95\\
HTM20 M000828-132930&00:08:28.02&-13:29:30.32&161&-&-&192&-&-&-&-0.07&-&-&-&0.96&--\\
HTM20 M000829-055845&00:08:29.33&-05:58:45.27&66&-&-&1322&-&-&-&-1.14&-&-&-&0.66&0.68\\
HTM20 M000831-141959&00:08:31.08&-14:19:59.93&53&-&-&604&-&-&-&-0.92&-&-&-&0.79&--\\
HTM20 M000837-461940&00:08:37.53&-46:19:40.85&75&98&95&-&114&-0.10&-0.06&-0.13&0.05&-0.17&-0.32&1.0&1.0\\
HTM20 M002122-513011&00:21:22.06&-51:30:11.9&49&59&56&-&45&0.12&0.12&0.03&0.21&-0.21&-0.22&1.11&--\\
HTM20 M002127-161028&00:21:27.55&-16:10:28.82&69&92&61&55&-&0.08&0.28&0.21&0.70&0.21&-0.34&0.95&1.01\\
HTM20 M002135-321637&00:21:35.67&-32:16:37.39&221&275&313&388&559&-0.17&-0.19&-0.21&-0.22&-0.24&-0.26&0.79&--\\
\hline
\end{longtable}
\end{landscape}
\end{document}
第一次运行 Latex 后,我们得到以下对齐问题:
日志文件包含
`Package longtable Warning: Table widths have changed. Rerun LaTeX.`
第二次运行得到所需的结果:
答案2
我使用了排除法来了解问题的根源。这是一份非常大的文档。因此,它包含的软件包比我上面列出的要多得多,可以提出这个问题。
当我评论一些东西的时候,我意识到使用这个选项
\pagestyle{scrheadings}
导致表格对齐混乱。警告如下:
Package longtable Warning: Table widths have changed. Rerun LaTeX.
会出现,无论我重新运行 LaTex 多少次,它都不会消失。
因此,目前的解决方案似乎是注释掉,\pagestyle{scrheadings}
因为它似乎与 longtable 包之间存在冲突。弄清楚了这一点后,我现在将尝试找到如何解决此冲突。
感谢大家的建议和时间。