latex multirow 内换行

latex 多行合并要用到 \multirow, 若合并后的内容还想换行,就要用到其他命令了:

方法一: 使用 \shortstack

举例:

\usepackage{booktabs}
\usepackage{multirow}
\begin{table}[!ht]
\begin{tabular}{clrrrrrr}
\toprule
Capacity constraint&\multicolumn{6}{c}{Optimal solutions}
\\
\midrule
\multirow{6}*{\shortstack{Cash constraint\\(Our model)}}&$x_{t}$  &1    &0    &1    &1    &0    &0\\
&$y_{t}$  &20    &0    &77    &20    &100    &0  \\
&$w_{t}$  &25    &18    &0    &0    &0    &0    \\
&$Ed_t$ &30    &33    &41    &55    &45    &55    \\
&$I_{t}$  &15    &0    &35    &0    &55    &0  \\
&$B_{t}$  &0    &330    &648    &1177    &952    &1942    \\
\bottomrule
\end{tabular}
\end{table}

效果:

这里写图片描述

方法二:使用 宏包 makecell 里面的 \multirowcell
举例:

\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}
\begin{table}[!ht]
\begin{tabular}{clrrrrrr}
\toprule
Capacity constraint&\multicolumn{6}{c}{Optimal solutions}
\\
\midrule
\multirowcell{6}{Cash constraint\\(Our model)}&$x_{t}$  &1    &0    &1    &1    &0    &0\\
&$y_{t}$  &20    &0    &77    &20    &100    &0  \\
&$w_{t}$  &25    &18    &0    &0    &0    &0    \\
&$Ed_t$ &30    &33    &41    &55    &45    &55    \\
&$I_{t}$  &15    &0    &35    &0    &55    &0  \\
&$B_{t}$  &0    &330    &648    &1177    &952    &1942    \\
\bottomrule
\end{tabular}
\end{table}

效果:
这里写图片描述

方法三:使用自定义命令 tabincell, 但感觉不好用,就不细说了

猜你喜欢

转载自blog.csdn.net/robert_chen1988/article/details/80861246
今日推荐