xltabular
我正在使用 以横向格式创建一个长表landscape
。我使用环境添加表格注释tablenotes
:
\begin{landscape}
\begin{xltabular}[l]{X X X X}
\caption{Table 1}
\label{Table 1}
Column 1 & Column 2 & Column 3 & Column 4
%here are a lot of rows over multiple pages
\begin{tablenotes}[flushleft]\scriptsize
\item This text breaks after the first column. I want the text to expand the whole page width.
\end{tablenotes}
\end{xltabular}
\end{landscape}
但是,文本在第一列之后就中断了。我希望文本能够扩展到整个页面宽度的所有列(类似于 \linewidth)。
你知道我怎样才能实现这个目标吗?
谢谢!
答案1
如果没有更多上下文,很难确切地说出你应该做什么。tablenotes
例如,我们需要你从中获取的包。例如threeparttable
,该包期望在(或等效)命令完成tablenotes
后出现。如果你真的想要在里面,你应该把它包装起来,这样它就跨越了所有四列,而不仅仅是在第一列。tabular
tablenotes
xltabular
\multicolumn{4}{X}{...}
答案2
以下是我如何根据您目前提供的代码片段构建 MWE:
\documentclass{article}
\usepackage{xltabular}
\usepackage{threeparttablex}
\usepackage{pdflscape}
\begin{document}
\begin{landscape}
\begin{ThreePartTable}
\begin{TableNotes}[flushleft]\scriptsize
\item This text breaks after the first column. I want the text to expand the whole page width.
\end{TableNotes}
\begin{xltabular}{\textwidth}{X X X X}
\caption{Table 1}
\label{Table 1}\\
\endhead
\insertTableNotes
\endfoot
Column 1 & Column 2 & Column 3 & Column 4
\end{xltabular}
\end{ThreePartTable}
\end{landscape}
\end{document}
答案3
对于跨页的长表格,您必须加载threeparttablex
,其语法略有不同:宣布TableNotes
在进入 xltabular 环境之前的环境,以及插入表格部分\insertTableNotes
中的命令带有注释。lastfoot
\documentclass{article}
\usepackage{lscape}
\usepackage{booktabs}
\usepackage{booktabs,caption}
\usepackage{xltabular, threeparttablex, makecell}
\usepackage{lipsum}
\begin{document}
\begin{landscape}
\begin{ThreePartTable}%
\setTableNoteFont{\footnotesize}
\setlength{\extrarowheight}{3pt}
\begin{TableNotes}[flushleft]
\item[]\lipsum[11]
\end{TableNotes}
\begin{xltabular}{\linewidth}{X X X X}
\caption{Table 1} \label{Table 1}\\
\toprule
Column 1 & Column 2 & Column 3 & Column 4 \\
\endhead
\bottomrule
\insertTableNotes \\
\endlastfoot
Some text some text some text some text some text some text some text some text & Some other text some other text some other text some other text some other text & & \\
\end{xltabular}
\end{ThreePartTable}
\end{landscape}
\end{document}