我正在创建一个具有交替行的表格 - 第一行有 5 列,第二行是仅由文本组成的合并列。
但是,我无论如何都无法让它换行。我试过hspan=minimal
、Q 列和 X 列(尽管可能不正确?)
提前致谢!
\begin{tblr}{
colspec={@{}c|Q[l]|c|c|c|@{}},
width=\linewidth
}
Thing 1 & Thing 2 & Thing 3 & Thing 4 & Thing 5\\
\SetCell[c=5]{c} I am a dummy string tall and skinny! Here is where I start start start! This is where I sing! There is my middle! And last we have my end end end!& & & & \\
\end{tblr}
答案1
您可以指定合并单元格的总宽度:
\documentclass{article}
\usepackage{tabularray}
\begin{document}
\begin{tblr}{
colspec={@{}X[c]|X[l]|X[c]|X[c]|X[c]|@{}},
width=\linewidth
}
Thing 1 & Thing 2 & Thing 3 & Thing 4 & Thing 5\\
\SetCell[c=5]{\linewidth,halign=l} I am a dummy string tall and skinny! Here is where I start start start! This is where I sing! There is my middle! And last we have my end end end!& & & & \\
\end{tblr}
\end{document}
(我c
用替换了您的列,X[c]
因此表格的宽度发生了变化,以均匀填充您指定的宽度,而不是只扩大最后一列。)
答案2
您可以使用选择器cell{row(s)}{column(s)}
定义多跨单元格。然后您应该使用hspan = minimal
正如所述tabularray 文档在 3.1.4 中Hspan 和 Vspan 算法:
\documentclass[12pt]{article}
\usepackage{tabularray}
% Random text
% Don't use this on your document
\usepackage{lipsum}
\begin{document}
\begin{tblr}{
colspec = {*{5}X},
hlines,
vlines,
% minimal span
hspan=minimal,
width = 1\columnwidth,
rows = {
valign = m,
halign = c
},
% cell in row 5 column 1 will have a
% colspan of 5 (c=5), for rowspan use r=#
cell{5}{1} = {c=5}{},
% alignment for row 5
row{5} = {
halign = j
},
}
1 & {835\\ 586} & 158 & 878 & 274 \\
2 & 285 & 608 & 904 & 285 \\
3 & 107 & 230 & 358 & 368 \\
4 & 415 & 301 & 182 & 147 \\
\lipsum[1] &&&&
\end{tblr}
% Termina nuestro documento
\end{document}