我有一个很长的桌面,有时里面会环绕很多文本。我宁愿不使用横向显示。
因此我使用 \ltxtable 包创建了以下测试。
核心代码为:
\documentclass[a4paper,oneside,centered,noparindent,noparskip]{bookest}
%\usepackage{showframe}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{ltxtable}
\usepackage{threeparttable}
\usepackage{textcomp}
\begin{document}
\LTXtable{\textwidth}{t3.tex}
\end{document}
而t3.tex文件的longtable代码是:
\begin{longtable}{lp{4.5cm}lp{6.5cm}} \toprule
% header ------------------------
\textnumero& Name \& Title & Dates & Events \\ \midrule
\endhead
1& King Soandso III & 2234 -- to date & This is some text \\
2& King Soandso III & 2234 -- 3456 & This is a lot of text that needs to be wrapped effectively\\
3& King Soandso III & 234 -- 134 (?)& This is some text \\
4& Queen Soandso III & 15thc -- 16thc (?) & This is a lot of text that needs to be wrapped effectively\\
5& King Soandso III ``The Radiant Light of the Sun over the Water of the Old Spring'' & 15thc -- 16thc (?) & This is a lot of text that needs to be wrapped effectively \\
6&&& This is some text \\
--&\multicolumn{3}{p{14.5cm}}{\textit{And what if there was a lot of text here that needed to be wrapped properly and elegantly to let the text breathe.}} \\
7&&& This is a lot of text that needs to be wrapped effectively \\
8&&& This is some text \\
9&&& This is a lot of text that needs to be wrapped effectively \\
10&&& This is some text \\ \bottomrule
\caption{Kings \& Queens.}
\end{longtable}
结果是这样的:
关于如何改进它,有什么建议吗?
例如,为什么标题出现在表格底部这么近的位置?“常规”表格不是这样的。
整个事情让人感觉......“丑陋”和尴尬就是最好的形容。
谢谢。
答案1
p
如果您需要跨列,则使用任何地方都会更简单p
,因为您知道要跨的列宽。我对齐了日期--
并将标题移到顶部。
\documentclass[oneside,centered,noparindent,noparskip]{bookest}
%\usepackage{showframe}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{longtable}
\usepackage{threeparttable}
\usepackage{textcomp}
\usepackage{array}
\begin{document}
\begin{longtable}{
@{}
>{\raggedright}p{.5cm}
p{4.5cm}
>{\raggedleft}p{1.5cm}@{}
>{\raggedright}p{2cm}
p{6.5cm}
@{}}
% header ------------------------
\caption{Kings \& Queens.}\\
\toprule
\multicolumn{1}{c}{\textnumero}&
\multicolumn{1}{c}{Name \& Title}&
\multicolumn{2}{c}{Dates}&
\multicolumn{1}{c}{Events}\\ \midrule
\endfirsthead
\caption[]{Kings \& Queens.}\\
\toprule
\multicolumn{1}{c}{\textnumero}&
\multicolumn{1}{c}{Name \& Title}&
\multicolumn{2}{c}{Dates}&
\multicolumn{1}{c}{Events}\\ \midrule
\endhead
1& King Soandso III & 2234 &-- to date & This is some text \\
2& King Soandso III & 2234 &-- 3456 & This is a lot of text that needs to be wrapped effectively\\
3& King Soandso III & 234 &-- 134 (?)& This is some text \\
4& Queen Soandso III & 15thc &-- 16thc (?) & This is a lot of text that needs to be wrapped effectively\\
5& King Soandso III ``The Radiant Light of the Sun over the Water of the Old Spring'' & 15thc &-- 16thc (?) & This is a lot of text that needs to be wrapped effectively \\
6&&&& This is some text \dotfill\\
--&\multicolumn{4}{p{\dimexpr14.5cm+4\tabcolsep}@{}}{%
\textit{And what if there was a lot of text here that needed to be wrapped properly and elegantly to let the text breathe.}} \\
7&&&& This is a lot of text that needs to be wrapped effectively \\
8&&&& This is some text \\
9&&&& This is a lot of text that needs to be wrapped effectively \\
10&&&& This is some text \\ \bottomrule
\end{longtable}
\end{document}