我正在尝试制作一个长桌双栏文章,需要继续下一页单列方式。因此我使用长桌环境。由于桌子也比较宽,所以我需要让它景观. 而且它有较长的列标题,列宽适合列标题文本宽度,我试过这个(代码如下)。但我需要让它适合横向模式下的页面长度。现在我只能看到页面的一半。问题在于如何在 longtable、landscape 和 twocolumn 环境下将较长的列标题(列内容也很长)分成多行?
我还发现了一些包板状的。但我没有找到任何关于此内容的文档。关于此内容的链接也很有帮助(我从 leaf 上获取了一个模板,但对我不起作用。)。
请帮助我。提前致谢。
\documentclass{article}
\usepackage{longtable}
\usepackage{pdflscape}
\title{A longtable + tabularx example, using xltabular}
\section{heokvkxdovk}
\begin{document}
\afterpage{%
\clearpage% Flush earlier floats (otherwise order might not be correct)
% \thispagestyle{empty}
\begin{landscape}
\centering
\begin{longtable} {|p{0.03cm}|p{0.08cm}|p{0.04cm}|p{0.15cm}|p{0.23cm}|p{0.12cm}|p{0.1cm}|p{0.1cm}|}
\caption{A sample wide and long table.} \label{tab:long} \\
\hline \multicolumn{1}{|c|}{\textbf{Study}} & \multicolumn{1}{|c|}{\textbf{Approach}} & \multicolumn{1}{|c|}{\textbf{Application No.}} & \multicolumn{1}{|c|}{\textbf{Concept Extraction or Concept Mapping model}} & \multicolumn{1}{|c|}{\textbf{Feature generation}} &\multicolumn{1}{|c|}{\textbf{Result}} & \multicolumn{1}{|c|}{\textbf{Input}} & \multicolumn{1}{|c|}{\textbf{Dataset}} \\ \hline
\endfirsthead
\multicolumn{8}{c}%
{\tablename\ \thetable{} -- continued from previous page} \\
\hline \multicolumn{1}{|c|}{\textbf{Study}} & \multicolumn{1}{|c|}{\textbf{Approach}} & \multicolumn{1}{|c|}{\textbf{Application No.}} & \multicolumn{1}{|c|}{\textbf{Concept Extraction or Concept Mapping model}} & \multicolumn{1}{|c|}{\textbf{Feature generation}} &\multicolumn{1}{|c|}{\textbf{Result}} & \multicolumn{1}{|c|}{\textbf{Input}} & \multicolumn{1}{|c|}{\textbf{Dataset}} \\ \hline
\endhead
\hline \multicolumn{8}{|r|}{{Continued on next page}} \\ \hline
\endfoot
\hline
\endlastfoot
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
\end{longtable}
\end{landscape}
}
\end{document}
答案1
- 正如我在评论中提到的,
longtable
它不适用于双列文档。若要在这样的文档中使用它,您需要将之前的文档更改longtable
为一种column
类型,之后将其返回为两列。这样,无论您使用什么afterpage
,表格前后都会留有空白。 - 不清楚实际表格主体中的单元格内容是否比您的(虚拟)表格示例中显示的更长。如果不是,那么
p{...}
最好使用列类型而不是列类型,例如l
列
编辑:
- 通过
\multicolumn{1}{c}{....}
在列标题中使用,您可以覆盖列规范。您应该删除它们的使用,并最终改为使用
\bfseries Study & \bfseries Approach & \bfseries Application No.
& \bfseries Concept Extraction or Concept Mapping model
& \bfseries Feature generation
& \bfseries Result
& \bfseries Input
& \bfseries Dataset \\ \hline
- 另一个解决方案是使用命令
thead{...}
中的命令makcell
并手动将列标题分成更多行,并在表格中使用例如l
列类型。但是,如果单元格中的文本较长,并且您希望自动将其分成更多行,那么此解决方案将无法获得所需的结果
您的表格的可能解决方案之一是:
\documentclass[twocolumn]{article} % two column document
\usepackage{longtable,
makecell} % new
\renewcommand\theadfont{\small\bfseries} % new
\usepackage{pdflscape}
\usepackage{afterpage} % new
\title{A longtable + tabularx example, using xltabular}
\usepackage{lipsum}
\begin{document}
\section{heokvkxdovk}
\lipsum[1-2]
\afterpage{%
\onecolumn
\begin{landscape}
\begin{longtable}{ | *{8}{l|} }
%{|p{0.03cm}|p{0.08cm}|p{0.04cm}|p{0.15cm}|
% p{0.23cm}|p{0.12cm}|p{0.1cm} |p{0.1cm}|}
\caption{A sample wide and long table.}
\label{tab:long} \\
\hline
\thead{Study} & \thead{Approach}
& \thead{Application\\ No.}
& \thead{Concept Extraction\\ or Mapping model}
& \thead{Feature\\ generation}
&\thead{Result}
& \thead{Input} & \thead{Dataset} \\
\hline
\endfirsthead
\caption[]{ -- continued from previous page} \\
\hline
\thead{Study} & \thead{Approach}
& \thead{Application\\ No.}
& \thead{Concept Extraction\\ or Mapping model}
& \thead{Feature\\ generation}
&\thead{Result}
& \thead{Input} & \thead{Dataset} \\
\hline
\endhead
\hline
\multicolumn{8}{r}{\footnotesize\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
%%%% table body
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
One & abcdef ghjijklmn & 123.456778 &One & abcdef ghjijklmn & 123.456778&One & abcdef ghjijklmn \\
\end{longtable}
\end{landscape}
\twocolumn
}
\lipsum
\end{document}
- 对于
xltabular
表格的使用,您需要决定所有列是否具有相同的宽度。在这种情况下,表格规范和文档序言可以是例如:
\documentclass[twocolumn]{article} % two column document
\usepackage{ragged2e} % new
\usepackage{xltabular} % new
\newcolumntype{L}{>{\RaggedRight}X} % new
\newcommand\bfc{\small\bfseries\hfil} % new
\usepackage{pdflscape}
\usepackage{afterpage}
\title{An example of use of the \texttt{xltabular} package}
\usepackage{lipsum}
\begin{document}
\maketitle
\section{heokvkxdovk}
\lipsum[1-2]
\afterpage{%
\onecolumn
\begin{landscape}
\setlength\tabcolsep{4pt}
\begin{xltabular}{\linewidth}{| c | *{7}{L|} }
\caption{A sample wide and long table.}
\label{tab:long} \\
\hline
\bfc Study & \bfc Approach
& \bfc App. No. *
& \bfc CE or MM *
& \bfc Feature g. *
& \bfc Result
& \bfc Input
& \bfc Dataset \\
\hline
\endfirsthead
\caption[]{ -- continued from previous page} \\
\hline
\bfc Study & \bfc Approach
& \bfc App. No. *
& \bfc CE or MM *
& \bfc Feature g. *
& \bfc Result
& \bfc Input
& \bfc Dataset \\
\hline
\endhead
\hline
\multicolumn{5}{p{0.5\linewidth}}{\small
App. No.: Application Number\newline
CE or MM: Concept Extraction or Mapping Model\newline
Feature g.: Feature generation}
&
\multicolumn{3}{r}{\footnotesize\textit{Continued on next page}} \\
\endfoot
\hline
\multicolumn{8}{p{\linewidth}}{\small
App. No.: Application Number\newline
CE or MM: Concept Extraction or Mapping Model\newline
Feature g.: Feature generation} \\
\endlastfoot
%%%% table body
\end{xltabular}
\end{landscape}
\twocolumn
}
\lipsum
\end{document}
生成(显示表格的最后一部分):
答案2
\onecolumn
\begin{landscape}
\begin{longtable}{|p{0.04\linewidth}|p{0.13\linewidth}|p{0.05\linewidth}|p{0.21\linewidth}|p{0.16\linewidth}|p{0.16\linewidth}|p{0.16\linewidth}|} %new
\caption{A sample wide and long table.}
\label{tab:long} \\
\hline
\thead{Study} & \thead{Approach}
& \thead{Applica- \\ tion No.}
& \thead{Concept Extraction\\ or Mapping model}
&\thead{Result}
& \thead{Input}
& \thead{Dataset} \\
\hline
\endfirsthead
\caption[]{ -- continued from previous page} \\
\hline
\thead{Study} & \thead{Approach}
& \thead{Applica \\tion No.}
& \thead{Concept Extraction\\ or Mapping model}
&\thead{Result}
& \thead{Input} & \thead{Dataset} \\
\hline
\endhead
\hline
\multicolumn{7}{r}{\footnotesize\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
%%%% table body
Dummy text &
Dummy text &
Dummy No &
Lengthy Dummy text my will spilt in multiple rows &
Dummy text&
Dummy text&
Dummy text \\
Dummy text &
Dummy text &
Dummy No &
Lengthy Dummy text my will spilt in multiple rows &
Dummy text&
Dummy text&
Dummy text\\
Dummy text &
Dummy text &
Dummy No &
Lengthy Dummy text my will spilt in multiple rows &
Dummy text&
Dummy text&
Dummy text\\
\end{longtable}
\end{landscape}
\twocolumn
}