Skip to content

跨页长表

mohuangrui edited this page Feb 21, 2019 · 16 revisions

方法一

跨页长图 类似 ,使用 \ContinuedFloat

\begin{table}[!htbp]
    \bicaption{这是一个样表。}{This is a sample table.}
    \label{tab:sample}
    \centering
    \footnotesize% fontsize
    \begin{tabular}{lcccccccc}
        \hline
        行号 & \multicolumn{8}{c}{跨多列的标题}\\
        \hline
        Row 1 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 2 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 3 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 4 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 5 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 6 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 7 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 8 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
    \end{tabular}
\end{table}
\begin{table}[!htbp]
    %\ContinuedFloat% continue splited float
    \bicaption{续表。}{Continued table.}
    \label{tab:sample}
    \centering
    \footnotesize% fontsize
    \begin{tabular}{lcccccccc}
        Row 9 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 10 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 11 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        Row 12 & $1$ & $2$ & $3$ & $4$ & $5$ & $6$ & $7$ & $8$\\
        \hline
    \end{tabular}
\end{table}

其效果如下: screen shot 2019-02-20 at 23 09 01

此方法的优势是无需调用额外的包裹,简单且容易实现复杂的标题。其劣势是需要手动分割表格。

方法二

使用 longtable 宏包。但由于 longtable 宏包自带的 caption 的设计不兼容 bicaption 宏包的如下两条位于 artratex.sty 中的命令( tex.se上 bicaption 的作者回答过这个问题,并进行了解决,只是奇怪的是问题仍存在)

\captionsetup[table][bi-first]{format=hang,hangindent=-0.5em}%
\captionsetup[table][bi-second]{format=hang,hangindent=-2em,name=Table}%

从而若使用 longtable 就需要注释掉上述行,但其导致的问题就是普通 table 的标题若用 bicaption 命令,则第二个标题无法是 “Table” 而是 “表”,解决的办法是:

注释掉 artratex.sty 中的如下行

%\captionsetup[table][bi-first]{format=hang,hangindent=-0.5em}%
%\captionsetup[table][bi-second]{format=hang,hangindent=-2em,name=Table}%

并在 artracom.sty 中调用 longtable 宏包:

\RequirePackage{longtable}

然后所有 table(包括普通的table和longtable)的双语标题的实现都如如下样例:

\begin{longtable}{|c|c|c|c|}
    \caption[这是一个样表]{这是一个样表\\Table~\ref{tab:longtab} A simple longtable example}\label{tab:longtab}\\
	\hline
	\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
	\hline
	\endfirsthead
	\multicolumn{4}{c}%
	{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
	\hline
	\textbf{First entry} & \textbf{Second entry} & \textbf{Third entry} & \textbf{Fourth entry} \\
	\hline
	\endhead
	\hline \multicolumn{4}{r}{\textit{Continued on next page}} \\
	\endfoot
	\hline
	\endlastfoot
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
	1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\ 1 & 2 & 3 & 4 \\
\end{longtable}

其结果如图

image

除此之外,longtable 的设计也存在无法正确处理字体命令的问题。从而如需改变字体大小,需采用如下形式:

{
\footnotesize% set font size for longtable
\begin{longtable}

\end{longtable}
}

最后,longtable 跨页所产生的英文注释,除非修改 longtable 宏包文件,应该无法解决。

Clone this wiki locally