我正在用 LaTex 构建一个包含一列图片的表格。我希望与这些图片相关的行的大小能够增加其高度,以便图片停留在其单元格内。我尝试了解决方案\\[2cm]
,但同一行单元格中的文本不再居中。举个更清楚的例子:
\documentclass[]{article}
\usepackage{multirow}
\begin{document}
\begin{table}[h!]
\begin{tabular}{c|c|c|c|c c c|c c c}
\multirow{ 2}{*}{} & \multirow{ 2}{*}{\textbf{mesh}} & \multirow{ 2}{*}{\textbf{dofs}} & \multirow{ 2}{*}{\textbf{levels}} & \multicolumn{3}{|c|}{\textbf{iterations}} & \multicolumn{3}{|c}{\textbf{Conv Rate}} \\ \cline{5-10}
& & & & \footnotesize{SGMG} & \footnotesize{NMG} & \footnotesize{AMG} & \footnotesize{SGMG} & \footnotesize{NMG} & \footnotesize{AMG}\\\hline
\multirow{ 2}{*}{\textbf{1D}} & \multirow{ 2}{*}{\includegraphics[scale = .2]{path1}& \multirow{ 2}{*}{100k} & 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \hline
\multirow{8}{*}{\textbf{2D}} & \multirow{ 2}{*}{\includegraphics[scale = .1]{path2}& \multirow{2}{*}{100k} & 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\[2cm] \cline{2-10}
& \multirow{ 2}{*}{mesh22} & \multirow{2}{*}{100k} & 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \cline{2-10}
&\multirow{ 2}{*}{mesh23} & \multirow{2}{*}{100k}& 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \cline{2-10}
& \multirow{ 2}{*}{mesh24}& \multirow{2}{*}{100k}& 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \hline
\end{tabular}
\end{table}
\end{document}
是否有一种简单的方法,只需放置图片并让所有其他文本居中显示在其他单元格中?
答案1
结合使用vspan=even
fromtabularray
包和valign=c
from adjustbox
:
\documentclass{article}
\usepackage{geometry}
\usepackage{graphicx}
\usepackage{tabularray}
\usepackage[export]{adjustbox}
\begin{document}
\begin{table}[h!]
\begin{tblr}{vspan=even}
\multirow{ 2}{*}{} & \multirow{ 2}{*}{\textbf{mesh}} & \multirow{ 2}{*}{\textbf{dofs}} & \multirow{ 2}{*}{\textbf{levels}} & \multicolumn{3}{|c|}{\textbf{iterations}} & \multicolumn{3}{|c}{\textbf{Conv Rate}} \\ \cline{5-10}
& & & & \footnotesize{SGMG} & \footnotesize{NMG} & \footnotesize{AMG} & \footnotesize{SGMG} & \footnotesize{NMG} & \footnotesize{AMG}\\\hline
%
\multirow{2}{*}{\textbf{1D}} & \multirow{ 2}{*}{\includegraphics[width=2cm, valign=c]{example-image}}& \multirow{ 2}{*}{100k} & 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \hline
%
\multirow{8}{*}{\textbf{2D}} & \multirow{ 2}{*}{\includegraphics[width=3cm, valign=c]{example-image}}& \multirow{2}{*}{100k} & 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \cline{2-10}
%
& \multirow{ 2}{*}{mesh22} & \multirow{2}{*}{100k} & 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \cline{2-10}
%
&\multirow{ 2}{*}{mesh23} & \multirow{2}{*}{100k}& 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \cline{2-10}
%
& \multirow{ 2}{*}{mesh24}& \multirow{2}{*}{100k}& 2 & -&- & - & - & - & - \\
& & & 5 & -& -& - & - & - & - \\ \hline
\end{tblr}
\end{table}
\end{document}
\end{document}