怎么在Latex中绘制可以自动换页的表格

发布网友

我来回答

2个回答

热心网友

在标准 LaTeX 中的表格是当做一个“盒子”来处理的,不能分割,所以无法跨页显示。
我们如何让一个表格跨页显示,通常有两个方案。
其一是使用longtable,其二是使用supertabular
http://blog.sina.com.cn/s/blog_5e16f1770100lix8.html

方案一:longtable

longtable宏包是 LaTeX 工具宏包套件之一,可用于跨页表格。它定义了一个长表环境,只需将tabular 环境改为 longtable 环境,跨页长表格就可自动拆分为多页表格。注意:使用长表环境后,须经两或三次编译,才能得到正确结果。
由于改变了原有输出方式,所以它不能用在 multicolumn 多栏环境或 twocolumn 双栏页面格式中。
http://yuxu9710108.blog.163.com/blog/static/23751534200852435737848/

\usepackage{longtable}
\begin{longtable}{|r|c|c|}
\caption{GPIO Pin AFN 配置表}\\ \hline
GPIO Pin & AFN &配置值\\ \hline
gpio0 &AFN1 &0x0000\_14C1\\
gpio1 &AFN1 &0x0000\_D5C1\\
...
gpio127 &AFN0 &0x0000\_D040\\ \hline
\end{longtable}

1.1 若想在每页开头都有表头,那么这样这样做
http://nepsweb.co.uk/docs/tableTricks.pdf 第14页

\usepackage{longtable}
\usepackage{array} % for extrarowheight
\setlength{\extrarowheight}{1.5pt}
\begin{longtable}{|l|l|}
% header ------------------------
\hline
Heading 1 & Heading 2 \\\hline\hline
\endhead
% header ------------------------
Lorem ipsum ... & Consectetur ... \\\hline
Lorem ipsum ... & Consectetur ... \\\hline
.
\end{longtable}
结果为

1.2 若想在两个表之间添加些说明,如见下页续表,可以这么做:
\begin{longtable}[l]{ c || c | c | c || c | c | c || c | c | c } \hline
\multirow{2}{*}{source}
& \multicolumn{3}{c||}{$\ee$} & \multicolumn{3}{c||}{$\mumu$} & \multicolumn{3}{c}{$\emu$} \\ \cline{2-10}
& $F_0$ & $F_L$ & $F_R$ & $F_0$ & $F_L$ & $F_R$ & $F_0$ & $F_L$ & $F_R$ \\
\hline
\hline
\endfirsthead

\multicolumn{10}{c}{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\multirow{2}{*}{source}
& \multicolumn{3}{c||}{$\ee$} & \multicolumn{3}{c||}{$\mumu$} & \multicolumn{3}{c}{$\emu$} \\ \cline{2-10}
& $F_0$ & $F_L$ & $F_R$ & $F_0$ & $F_L$ & $F_R$ & $F_0$ & $F_L$ & $F_R$ \\
\hline
\hline
\endhead

\hline
\multicolumn{10}{c}{\textit{Continued on next page}} \\
\endfoot
\endlastfoot

JES FlavorResponse & $<0.004$ & $<0.008$ & $<0.004$ & $<0.007$ & $<0.009$ & $<0.002$ & $<0.006$ & $<0.008$ & $<0.002$ \\
Jet energy scale p00 & $0.004$ & $0.008$ & $ 0.004$ & $ 0.007$ & $ 0.009$ & $ 0.002$ & $ 0.006$ & $ 0.008$ & $ 0.002$ \\
% 40 hang
\caption{Systematic uncertainty}
\label{tab:whelChnSyst}
\end{longtable}

显然上面的表格是超过了文本宽度,
1.2.1 我按照下面的参考链接去做,没有成功,不知道为什么!
http://cs.brown.e/system/software/latex/doc/longtable.pdf (第七页,5 Adjustment)
http://stackoverflow.com/questions/2563514/wide-and-long-table-in-latex
http://tex.stackexchange.com/questions/815/longtable-in-latex-too-wide
http://tex.stackexchange.com/questions/46511/how-to-set-width-of-longtable
http://www.techques.com/question/1-11663737/longtable-in-LaTeX-to-wide
http://www.zomeon.com/1110961/latex-longtable-package-pwidth-and-multicolumn-question

如表格过宽的处理所言,是不起作用的,因为他们把表格当成了一个box,而box是不能切割的。
http://blog.163.com/chen_dawn/blog/static/1125063201321113318196/
\footnotesize 也不起作用,让我感到疑惑。

1.2.2 可以用旋转
http://bbs.ctex.org/forum.php?mod=viewthread&tid=30557
\usepackage{longtable,lscape}
\begin{landscape}
\begin{longtable}
......
\end{longtable}
\end{landscape}

1.2.3 可以缩小字体
http://bbs.ctex.org/forum.php?mod=viewthread&tid=38084
\begin{footnotesize}
\begin{longtable}
......
\end{longtable}
\end{footnotesize}

Latex 设置字体大小命令由小到大依次为:
\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge
理论上该有其他的方式来解决这个问题,但是我没找到,若您知道,还请告知:如告知参考资料,提供列子等。

方案二:使用supertabular 参看。 http://www.ctan.org/tex-archive/macros/latex/contrib/supertabular/supertabular.pdf

该宏包提供了一个 supertabular 环境,是对 tabular 环境的扩充。它能不断地计算表格长度,当排版到页面底部时,自动结束 tabular 环境,而在下一页再自动生成一个新的 tabular 环境,将剩余表格放入其中。
使用该宏包排版长表格时,要用所提供的生成命令专门设计表头,具体方法可参考文中的示例。
摘录文中示例如下:需要\usepackage{supertabular} % 太复杂

\begin{center}
\tablefirsthead{%
\hline
\multicolumn{1}{|c}{\tbsp Number} &
\multicolumn{1}{c}{Number$^2$} &
Number$^4$ &
\multicolumn{1}{c|}{Number!} \\
\hline}
\tablehead{%
\hline
\multicolumn{4}{|l|}{\small\sl continued from previous page}\\
\hline
\multicolumn{1}{|c}{ Number} &
\multicolumn{1}{c}{Number$^2$} &
Number$^4$ &
\multicolumn{1}{c|}{Number!} \\
\hline}
\tabletail{%
\hline
\multicolumn{4}{|r|}{\small\sl continued on next page}\\
\hline}
\tablelasttail{\hline}
\bottomcaption{This table is split across pages}
\tablefirsthead{%
\hline
\multicolumn{1}{|c}{\tbsp Number} &
\multicolumn{1}{c}{Number$^2$} &
Number$^4$ &
\multicolumn{1}{c|}{Number!} \\
\hline}
\tablehead{%
\hline
\multicolumn{4}{|l|}{\small\sl continued from previous page}\\
\hline
\multicolumn{1}{|c}{ Number} &
\multicolumn{1}{c}{Number$^2$} &
Number$^4$ &
\multicolumn{1}{c|}{Number!} \\
\hline}
\tabletail{%
\hline
\multicolumn{4}{|r|}{\small\sl continued on next page}\\
\hline}
\tablelasttail{\hline}
\bottomcaption{This table is split across pages}
\tablefirsthead{%
\hline
\multicolumn{1}{|c}{ Number} &
\multicolumn{1}{c}{Number$^2$} &
Number$^4$ &
\multicolumn{1}{c|}{Number!} \\
\hline}
\tablehead{%
\hline
\multicolumn{4}{|l|}{\small\sl continued from previous page}\\
\hline
\multicolumn{1}{|c}{ Number} &
\multicolumn{1}{c}{Number$^2$} &
Number$^4$ &
\multicolumn{1}{c|}{Number!} \\
\hline}
\tabletail{%
\hline
\multicolumn{4}{|r|}{\small\sl continued on next page}\\
\hline}
\tablelasttail{\hline}
\bottomcaption{This table is split across pages}
\begin{supertabular}{|r@{\hspace{6.5mm}}|r@{\hspace{5.5mm}}|r|r|}
1 & 1 & 1 & 1 \\
2 & 4 & 16 & 2 \\
3 & 9 & 81 & 6 \\
4 & 16 & 256 & 24 \\[5mm]
19 & 361 & 130321 & 1.215100E 17\\
20 & 400 & 160000 & 2.43290200E 18\\
2 & 4 & 16 & 2 \\
3 & 9 & 81 & 6 \\
4 & 16 & 256 & 24 \\[5mm]
19 & 361 & 130321 & 1.215100E 17\\
20 & 400 & 160000 & 2.43290200E 18\\
2 & 4 & 16 & 2 \\
3 & 9 & 81 & 6 \\
4 & 16 & 256 & 24 \\[5mm]
19 & 361 & 130321 & 1.215100E 17\\
20 & 400 & 160000 & 2.43290200E 18\\
2 & 4 & 16 & 2 \\
3 & 9 & 81 & 6 \\
4 & 16 & 256 & 24 \\[5mm]
19 & 361 & 130321 & 1.215100E 17\\
20 & 400 & 160000 & 2.43290200E 18\\
2 & 4 & 16 & 2 \\
3 & 9 & 81 & 6 \\
4 & 16 & 256 & 24 \\[5mm]
19 & 361 & 130321 & 1.215100E 17\\
20 & 400 & 160000 & 2.43290200E 18\\2 & 4 & 16& 2 \\
3 & 9 & 81 & 6 \\
4 & 16 & 256 & 24 \\[5mm]
19 & 361 & 130321 & 1.215100E 17\\
20 & 400 & 160000 & 2.43290200E 18\\2 & 4 & 16& 2 \\
3 & 9 & 81 & 6 \\
4 & 16 & 256 & 24 \\[5mm]
19 & 361 & 130321 & 1.215100E 17\\
20 & 400 & 160000 & 2.43290200E 18\\
\end{supertabular}
\end{center}

热心网友

放在页首比较简单,在图表前插入一个分页符,那不管前面有多少空,图表都会到下一页。 页尾暂时没想到办法。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com