![长表,标题为:“表 1”(第一页)和“表 1 续”(第二页)](https://linux22.com/image/376944/%E9%95%BF%E8%A1%A8%EF%BC%8C%E6%A0%87%E9%A2%98%E4%B8%BA%EF%BC%9A%E2%80%9C%E8%A1%A8%201%E2%80%9D%EF%BC%88%E7%AC%AC%E4%B8%80%E9%A1%B5%EF%BC%89%E5%92%8C%E2%80%9C%E8%A1%A8%201%20%E7%BB%AD%E2%80%9D%EF%BC%88%E7%AC%AC%E4%BA%8C%E9%A1%B5%EF%BC%89.png)
如果有人能帮助我将我的长表格分成两页并加上标题:“表格 1”(第一页)和“表格 1 续”(第二页),我将不胜感激。
我的MWE如下:
\documentclass[preprint, authoryear]{elsarticle}
%\usepackage{lineno,hyperref}
%\modulolinenumbers[5]
\usepackage[colorlinks=true,linkcolor=black, citecolor=blue, urlcolor=blue]{hyperref}
\journal{Journal of Transportation Research, Part E}
\usepackage{graphicx}
\usepackage{natbib}
\usepackage{textcomp}
\usepackage{textcomp}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{makecell, multirow}
\usepackage{url}
\usepackage{amstext}
\usepackage{amssymb}
\usepackage{amsmath}
%% \numberwithin{equation}{subsection}
\usepackage{multicol}
\setlength{\columnsep}{1cm}
\usepackage{tikz}
\usepackage{lettrine}
\allowdisplaybreaks
\usepackage[export]{adjustbox}
\usepackage{ragged2e}
\usepackage{subfig}
\usepackage{float}
\usepackage{url}
\urlstyle{same}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{array}
\usepackage{tabu}
\usepackage{boldline}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}
\begin{table}[h]
%\vspace{-6.5em}%
\caption{Notations}
\label{tab: DenoteTabl}
\setlength\extrarowheight{2pt}
\centering
\begin{tabularx}{\linewidth}{|c X|}
\hline
\multicolumn{2}{|c|}{Sets} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\multicolumn{2}{|c|}{Parameters} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\multicolumn{2}{|c|}{Variables} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\end{tabularx}
\end{table}
\end{document}
此外,我还看到了一段代码此链接使用longtable
包。但是,我需要的是两列的多列(一列宽度较短,另一列宽度灵活),但在那个例子中,它是四列的多列。此外,我需要根据文本块的宽度调整表格的宽度\textwidth
。所以,那个示例代码对我来说没用。
答案1
为了实现您要求的布局,存在许多不同的可能性,并且“自动化程度”各不相同。下面显示的所有示例都会产生以下输出或非常类似的输出:
1:第一个例子使用tabularx
的X
列作为第二列,并额外加载以向表中ltablex
添加longtable
功能tabularx
:
\documentclass[preprint, authoryear]{elsarticle}
\usepackage{tabularx}
\usepackage{ltablex}
\keepXColumns
\begin{document}
{
\setlength\extrarowheight{2pt}
\centering
\begin{tabularx}{\linewidth}{|c X|}
\caption{Notations}
\label{tab: DenoteTabl}
\endfirsthead
\caption{Notations (continued)}
\endhead
\hline
\multicolumn{2}{|c|}{Sets} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\multicolumn{2}{|c|}{Parameters} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\multicolumn{2}{|c|}{Variables} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\end{tabularx}
}
\end{document}
2:第二个示例利用了与以下包结合加载时tabu
提供环境的包:longtabu
longtable
\documentclass[preprint, authoryear]{elsarticle}
\usepackage{longtable}
\usepackage{tabu}
\begin{document}
\setlength\extrarowheight{2pt}
\begin{longtabu}to \linewidth{|c X|}
\caption{Notations}
\label{tab: DenoteTabl}
\endfirsthead
\caption{Notations (continued)}
\endhead
\hline
\multicolumn{2}{|c|}{Sets} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\multicolumn{2}{|c|}{Parameters} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\multicolumn{2}{|c|}{Variables} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\end{longtabu}
\end{document}
3:第三个示例利用了环境本身。这里,使用和包longtable
手动计算了使表格填充线宽所需的第二列宽度。calc
array
\documentclass[preprint, authoryear]{elsarticle}
\usepackage{longtable}
\usepackage{array}
\usepackage{calc}
\begin{document}
\setlength\extrarowheight{2pt}
\begin{longtable}{|p{0.4cm} p{\linewidth-0.4cm-4\tabcolsep-2\arrayrulewidth}|}
\caption{Notations}
\label{tab: DenoteTabl}
\endfirsthead
\caption{Notations (continued)}
\endhead
\hline
\multicolumn{2}{|c|}{Sets} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\multicolumn{2}{|c|}{Parameters} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\multicolumn{2}{|c|}{Variables} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\end{longtable}
\end{document}
4:第四个示例是更加手动的方法。由于我假设您想在给定点处拆分表格,并且不希望表格浮动,因此您也可以手动拆分它。对于标题,我使用了包capt-of
的命令captionof
。为了统一对表格的两个部分进行编号,我在两个表格之间将表格计数器向后移动了一个。
\documentclass[preprint, authoryear]{elsarticle}
\usepackage{tabularx}
\usepackage{capt-of}
\begin{document}
{\centering
\setlength\extrarowheight{2pt}
\captionof{table}{Notations}
\label{tab: DenoteTabl}
\begin{tabularx}{\linewidth}{|c X|}
\hline
\multicolumn{2}{|c|}{Sets} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\multicolumn{2}{|c|}{Parameters} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\end{tabularx}
\newpage
\addtocounter{table}{-1}
\captionof{table}{Notations (continued)}
\begin{tabularx}{\linewidth}{|c X|}
\hline
\multicolumn{2}{|c|}{Variables} \\ \hline
$A$ & text text text text text text text text text text $y$\\
$B$ & text text ${\left\langle{i,j}\right\rangle}$\\
$C$ & text text text text $g$ \\
$D$ & text text text text , indexed by $k$ \\
$E$ & text text text text , indexed by $r$\\
$F$ & text text text text , indexed by $yt$, $yt\in \{cl,tr\}$ \\
$G$ & text text text text text text , indexed by $bp$ \\ \hline
\end{tabularx}
}
\end{document}