我试图理解为什么当我应用时,我的 Latex 代码会将文本换行到第 2 列\linewidth
。列名有足够的空间。我只是希望标题的名称能够写出来并自动适应列内容的大小。
\usepackage{longtable}
\newlength{\asdf}
\setlength{\asdf}{\textwidth}
\begin{longtabu} to \linewidth {>{\raggedright}X>{\raggedright}X>{\raggedleft}X>{\raggedleft}X}
\caption{My caption.}\\
\toprule
\textbf{Index} & \textbf{Unique expression} & \textbf{\textit{n}} & \textbf{\%}\\
\midrule
\endhead
\midrule
\multicolumn{4}{r}{\footnotesize(To be continued)}
\endfoot
\endlastfoot
\addlinespace
1 & pa & 610 & 29.16\\
2 & tsa & 462 & 22.08\\
3 & ta & 305 & 14.58\\
4 & wa & 90 & 4.30\\
5 & pam & 75 & 3.59\\
6 & gwa & 57 & 2.72\\
7 & ya & 52 & 2.49\\
8 & pum & 43 & 2.06\\
9 & wam & 41 & 1.96\\
10 & sta & 37 & 1.77\\
11 & tsan & 29 & 1.39\\
12 & um & 28 & 1.34\\
13 & gwam & 23 & 1.10\\
\bottomrule
\end{longtabu}
我尝试了其他方法来引入长表格:%\begin{longtabu}{@{}rrll@{}}
,但是,虽然列没有被包裹起来,但表格并不宽达一页。
[目前的解决方法]和
\begin{longtable}{@{\extracolsep{\fill}}cccc@{}}
答案1
和tabularray
:
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\SetTblrStyle{contfoot}{font=\footnotesize\itshape}
\begin{document}
\begin{longtblr}[
caption = {My caption.},
label = {longtab:1}
]{width=0.5\linewidth,
colspec = {Q[c, m, si={table-format=2.0}]
X[l, m]
Q[c, m, si={table-format=3.0}]
Q[c, m, si={table-format=2.2}]
},
row{1} = {guard, font=\bfseries},
rowsep = 0pt,
row{odd[2-X]} = {belowsep=1ex},
rowhead = 1
}
\toprule
Index
& Unique expression
& \textit{n}
& \% \\
\midrule
1 & pa & 610 & 29.16 \\
2 & tsa & 462 & 22.08 \\
3 & ta & 305 & 14.58 \\
4 & wa & 90 & 4.30 \\
5 & pam & 75 & 3.59 \\
6 & gwa & 57 & 2.72 \\
7 & ya & 52 & 2.49 \\
8 & pum & 43 & 2.06 \\
9 & wam & 41 & 1.96 \\
10 & sta & 37 & 1.77 \\
11 & tsan & 29 & 1.39 \\
12 & um & 28 & 1.34\\
13 & gwam & 23 & 1.10\\
1 & pa & 610 & 29.16 \\
2 & tsa & 462 & 22.08 \\
3 & ta & 305 & 14.58 \\
4 & wa & 90 & 4.30 \\
5 & pam & 75 & 3.59 \\
6 & gwa & 57 & 2.72 \\
7 & ya & 52 & 2.49 \\
8 & pum & 43 & 2.06 \\
9 & wam & 41 & 1.96 \\
10 & sta & 37 & 1.77 \\
11 & tsan & 29 & 1.39 \\
12 & um & 28 & 1.34\\
13 & gwam & 23 & 1.10\\
1 & pa & 610 & 29.16 \\
2 & tsa & 462 & 22.08 \\
3 & ta & 305 & 14.58 \\
4 & wa & 90 & 4.30 \\
5 & pam & 75 & 3.59 \\
6 & gwa & 57 & 2.72 \\
7 & ya & 52 & 2.49 \\
8 & pum & 43 & 2.06 \\
9 & wam & 41 & 1.96 \\
10 & sta & 37 & 1.77 \\
11 & tsan & 29 & 1.39 \\
12 & um & 28 & 1.34\\
13 & gwam & 23 & 1.10\\
1 & pa & 610 & 29.16 \\
2 & tsa & 462 & 22.08 \\
3 & ta & 305 & 14.58 \\
4 & wa & 90 & 4.30 \\
5 & pam & 75 & 3.59 \\
6 & gwa & 57 & 2.72 \\
7 & ya & 52 & 2.49 \\
8 & pum & 43 & 2.06 \\
9 & wam & 41 & 1.96 \\
10 & sta & 37 & 1.77 \\
11 & tsan & 29 & 1.39 \\
12 & um & 28 & 1.34\\
13 & gwam & 23 & 1.10\\
1 & pa & 610 & 29.16 \\
2 & tsa & 462 & 22.08 \\
3 & ta & 305 & 14.58 \\
4 & wa & 90 & 4.30 \\
5 & pam & 75 & 3.59 \\
6 & gwa & 57 & 2.72 \\
7 & ya & 52 & 2.49 \\
8 & pum & 43 & 2.06 \\
9 & wam & 41 & 1.96 \\
10 & sta & 37 & 1.77 \\
11 & tsan & 29 & 1.39 \\
12 & um & 28 & 1.34\\
13 & gwam & 23 & 1.10\\
\bottomrule
\end{longtblr}
\end{document}