如题,我在使用 tabularray 宏包时,因为文本内容比较长,有时会在单元格内部换行,这时遇到单元格遇到不能控制单元格内部行距的问题。虽然使用 stretch 选项可以控制单元格的行高,但这似乎不能影响单元格内部的行距,一个示例如下(使用 TeX Live 2023 集成的 XeLaTeX 排版):
\documentclass{article}
\usepackage{tabularray}
\usepackage{ctex}
\begin{document}
\begin{tblr}{colspec = {ll}, hlines, stretch = {-1}, column{1} = {2\ccwd}, column{2} = {4\ccwd}}
\SetCell[r = 2]{l, h}\textbf{巻一} & 〇〇〇〇 \\
& 〇〇〇〇〇\\
\SetCell[r = 2]{l, h}\textbf{巻二} & 〇〇〇〇〇\\
& 〇〇〇〇〇\\
\textbf{巻三} & 〇〇〇〇〇\\
\end{tblr}
\vspace{1\baselineskip}
\begin{tblr}{colspec = {ll}, hlines, stretch = {1}, column{1} = {2\ccwd}, column{2} = {4\ccwd}}
\SetCell[r = 2]{l, h}\textbf{巻一} & 〇〇〇〇 \\
& 〇〇〇〇〇\\
\SetCell[r = 2]{l, h}\textbf{巻二} & 〇〇〇〇〇\\
& 〇〇〇〇〇\\
\textbf{巻三} & 〇〇〇〇〇\\
\end{tblr}
\end{document}
其编译实例如下:
可见上例中虽然设置 stretch = -1,单元格内部断行时其行距却和下例中 stretch = 1 的情况一致。
可以用 setspace
包,给需要的单元格添加控制行距的命令cmd=\setstretch{1}
来实现
\documentclass{article}
\usepackage{tabularray}
\usepackage{setspace}
\usepackage{ctex}
\begin{document}
\begin{tblr}{colspec = {ll}, hlines, stretch = {-1}, column{1} = {2\ccwd}, column{2} = {4\ccwd,cmd=\setstretch{1}}}
\SetCell[r = 2]{l, h}\textbf{巻一} & 〇〇〇〇 \\
& 〇〇〇〇〇\\
\SetCell[r = 2]{l, h}\textbf{巻二} & 〇〇〇〇〇\\
& 〇〇〇〇〇\\
\textbf{巻三} & 〇〇〇〇〇\\
\end{tblr}
\vspace{1\baselineskip}
\begin{tblr}{colspec = {ll}, hlines, stretch = {1}, column{1} = {2\ccwd}, column{2} = {4\ccwd}}
\SetCell[r = 2]{l, h}\textbf{巻一} & 〇〇〇〇 \\
& 〇〇〇〇〇\\
\SetCell[r = 2]{l, h}\textbf{巻二} & 〇〇〇〇〇\\
& 〇〇〇〇〇\\
\textbf{巻三} & 〇〇〇〇〇\\
\end{tblr}
\end{document}
可以使用setspace宏包的\setstrectch
命令结合tblr的cell
或cells
的cmd
参数实现,如:
\documentclass{article}
\usepackage{tabularray}
\usepackage{ctex}
\usepackage{setspace}
\begin{document}
\begin{tblr}{colspec = {ll}, hlines,%
cells={cmd=\setstretch{0.8}},%
column{1} = {2\ccwd}, column{2} = {4\ccwd}}
\SetCell[r = 2]{l, h}\textbf{卷一} & 〇〇〇〇 \\
& 〇〇〇〇〇\\
\SetCell[r = 2]{l, h}\textbf{卷二} & 〇〇〇〇〇\\
& 〇〇〇〇〇\\
\textbf{卷三} & 〇〇〇〇〇\\
\end{tblr}
\end{document}
其结果为:
感谢回复!现在试了一试,发现用 cmd = {setlengthbaselineskip{}} 也能有解。tabularray 的扩展性确实强大。