我有 4 列,每列都有长文本。如果尝试以下代码,文本会溢出到下一列: ]1
\documentclass{article}
\usepackage{longtable}
\usepackage{multirow}
\title{A longtable example}
\begin{document}
\begin{center}
\begin{longtable}{p{2.8cm} p{2.8cm}p{2.8cm}p{2.8cm}}
\caption{A sample long table.} \label{tab:long} \\
\hline \multicolumn{1}{c}{\textbf{First column}} & \multicolumn{1}{c}{\textbf{Second column}} & \multicolumn{1}{c}{\textbf{Third column}}&
\multicolumn{1}{c}{\textbf{TForth column}}\\ \hline
\endfirsthead
\multirow{4}{c}%
{{\bfseries \tablename\ \thetable{} -- continued from previous page}} \\
\hline \multicolumn{1}{c}{\textbf{Reference}} & \multicolumn{1}{c}{\textbf{techniqued}} & \multicolumn{1}{c}{\textbf{issues}}
\multicolumn{1}{c}{\textbf{future}}\\ \hline
\endhead
\hline \multicolumn{4}{r}{{Continued on next page}} \\ \hline
\endfoot
\hline \hline
\endlastfoot
\multirow{4}{*} textttttttttttttttttttttttt & abcdef ghjijklmn & 123.456778 & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 \\
\end{longtable}
\end{center}
\end{document}][1]][1]
我想将长文本限制在每个特定的列中。
答案1
- 的语法
\multirow{4}{*} textttttttttttttttttttttttt
错误。缺少 周围的花括号textttttttttttttttttttttttt
:\multirow{4}{*}{textttttttttttttttttttttttt}
- 如果您希望
multirow
cel 具有与所在列规定的相同宽度,那么您可以利用新的multirow
标题选项:\multirow{4}{=}{textttttttttttttttttttttttt}
- 位置上的单词
textttttttttttttttttttttttt
不是自然单词,这是断字规则所考虑的,因此您可以手动插入断字点。例如:text\-ttttt\-tttt\-tttttt\-ttt\-ttttt
- 不清楚你为什么使用
\multirow
单元格。其内容只是移动到下方并覆盖其下方的行。
无关:
- 使用包
\thead
中的命令makecell
可以简化列标题的编写 S
对于最后两列的数字,使用包中定义的列类型似乎siunitx
比类型更合适p
。
综合考虑以上因素,结果表如下:
(红线标记页面布局)
\documentclass{article}
%---------------- show page layout. don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%
\usepackage{longtable, makecell}
\renewcommand\theadfont{\small\bfseries}
\usepackage{siunitx}
\title{A longtable example}
\begin{document}
\begin{longtable}{ *{2}{p{2.8cm}}
*{2}{S[table-format=3.6]}}
\caption{A sample long table.}
\label{tab:long} \\
\hline
\thead{First\\ column}
& \thead{Second\\ column}
& {\thead{Third\\ column}}
& {\thead{Forth\\ column}} \\
\hline
\endfirsthead
\caption[]{A sample long table -- continued from previous page} \\
\hline
\thead{First\\ column}
& \thead{Second\\ column}
& {\thead{Third\\ column}}
& {\thead{Forth\\ column}} \\
\hline
\endhead
\hline
\multicolumn{4}{r}{\footnotesize\textit{Continued on next page}} \\
\endfoot
\hline \hline
\endlastfoot
text\-ttttt\-tttt\-tttttt\-ttt\-ttttt
& abcdef ghjijklmn & 123.456778 & 123.456778 \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
One & abcdef ghjijklmn & 123.456778 & \\
\end{longtable}
\end{document}