如何调整Tabularray生成的LaTeX表格高度(总行高/单行高)以缩小表格尺寸
Hey there! Since you're using the tabularray package for your LaTeX table, we’ve got two solid ways to shrink its height—and adjusting row spacing will give you the most natural, clean visual result. Let’s break this down:
方法一:调整行间距(推荐)
This is the best approach because it tweaks the vertical space between rows without distorting your content. Just add the rowsep parameter to your tblr options, setting it to a smaller value than the default (the default is usually around 4pt).
修改后的完整代码
\begin{table}[h!] \centering \caption[转换表]{Mach等人提出的转换方法。深色单元格中的Y:强烈推荐,浅色单元格中的Y:可用,深色单元格中的N:不可用 \label{tab:power}} \begin{tblr}{ colspec={lXXXXX}, vlines, hlines, cells={halign=c}, column{1-2}={halign=l}, vspan=even, rowsep=2pt, % 新增行间距设置,可按需调整为1pt/1.5pt等 cell{1}{2}={halign=c,bg=gray,fg=white}, cell{2}{1}={bg=gray,fg=white}, cell{3}{5-6}={bg=lightgray,font=\bfseries}, cell{5}{4-6}={bg=lightgray,font=\bfseries}, cell{6}{3}={bg=lightgray,font=\bfseries}, } & \SetCell[c=5]{} 分布类型 & & & & &\\ \SetCell[r=5]{} \rotatebox{90}{\parbox{3.5cm}{\centering 转换类型}} & & Lognormal & Exponential & Gamma & Weibull \\ & Box-Cox & Y & Y & Y & Y \\ & Exponential & Y & Y & Y & Y\\ & Simple power & Y & Y & Y & Y \\ & Logarithmic & Y & Y & N & N \\ \end{tblr} \end{table}
You can adjust the rowsep value (like 1pt or 1.5pt) to get exactly the height you want—smaller numbers mean a tighter table, just make sure the text doesn’t look cramped.
方法二:强制设置表格总高度
If you need the table to fit an exact height (e.g., for page layout constraints), you can use the height parameter in tblr, plus stretch=0 to prevent content from being stretched unnaturally. Here’s how that would look:
修改示例代码片段
\begin{tblr}{ colspec={lXXXXX}, vlines, hlines, cells={halign=c}, column{1-2}={halign=l}, vspan=even, height=5cm, % 强制表格总高度,按需修改数值 stretch=0, % 禁止自动拉伸内容,避免视觉变形 % 其他cell样式参数保持不变... }
Note that this method might make rows feel uneven if the height is set too small, so only use it if you have a strict height requirement.
内容的提问来源于stack exchange,提问作者Abbas




