带有表格环境的图

带有表格环境的图

我正在尝试创建一个图形,即带有该图形的表格tabular

\documentclass[a4paper]{article}
\usepackage[left=20mm,
            right=20mm,
            bottom=30mm,
            top=30mm]{geometry}
\usepackage{multirow,multicol} 
\usepackage{graphicx,tabularx,longtable}


% Rotated text inside tables
\newcommand{\spheading}[2][1]{% \spheading[<width>]{<stuff>}
    \rotatebox{90}{\parbox{#1}{\centering #2}}
}

\begin{document}
\bgroup
\def\arraystretch{1.5}\setlength{\tabcolsep}{3.5pt}
\begin{figure}[!htb]
    \centering
    \begin{tabular}{c*3{l}}
        \hline
        \multicolumn{1}{>{\centering\arraybackslash}m{.1\linewidth}}{Block Method}
        & \multicolumn{1}{>{\centering\arraybackslash}c}{EIT} 
        & \multicolumn{1}{>{\centering\arraybackslash}c}{mSDT} 
        & \multicolumn{1}{>{\centering\arraybackslash}c}{SLT} \\ \hline
        \spheading[7em]{\small $N_b = 2$}
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-a}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-b}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-c}
        } \\ \hline
          \spheading[7em]{\small $N_b = 4$}
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-a}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-b}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-c}
        } \\ \hline
          \spheading[7em]{\small $N_b = 5$}
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-a}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-b}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=0.41]{example-image-c}
        }\\ \hline
        \spheading[7em]{\small $N_b = 10$}
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-a}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-b}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-c}
        } \\ \hline
        \spheading[7em]{\small $N_b = 20$}
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-a}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-b}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-c}
        } \\ \hline
        \spheading[7em]{\small $N_b = 40$}
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-a}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-b}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-c}
        } \\ \hline
        \spheading[7em]{\small $N_b = 50$}
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-a}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-b}
        }
        & \raisebox{-.5em}{%
            \includegraphics[scale=.41]{example-image-c}
        } \\ \hline
    \end{tabular}
    \caption{Example.}
    \label{fig:BlockComparison_MatDist_pa=12}
\end{figure}
\egroup

\end{document}

因此,我做到了:

在此处输入图片描述

我想知道如何:

  • 对齐第一列的文本;
  • 增加每行的长度(这样图形就不会粘在每条水平线上,并且
  • 将此图分成两页。

谢谢建议

答案1

我认为您不想旋转第一列中的项目。

我不会使用scale,而更喜欢设置宽度。规则上方和下方的空间可以通过\midrule和 设置规则上方的垂直空间与下方相同(默认情况下不需要)。

要使图像垂直居中,请使用valign=c提供的adjustbox

\documentclass[a4paper]{article}
\usepackage[
  left=20mm,
  right=20mm,
  bottom=30mm,
  top=30mm
]{geometry}
\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{booktabs}

\begin{document}

\begin{figure}[!htb]
\centering

\setlength{\aboverulesep}{\belowrulesep}

\begin{tabular}{@{} cccc @{} }
\toprule
 & \multicolumn{3}{c}{Block Method} \\
 \cmidrule(l){2-4}
 & EIT & mSDT & SLT \\
\midrule
$N_b = 2$
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-a}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-b}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-c} \\
\midrule
$N_b = 4$
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-a}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-b}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-c} \\
\midrule
$N_b = 5$
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-a}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-b}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-c} \\
\midrule
$N_b = 10$
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-a}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-b}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-c} \\
\midrule
$N_b = 20$
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-a}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-b}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-c} \\
\midrule
$N_b = 40$
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-a}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-b}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-c} \\
\midrule
$N_b = 50$
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-a}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-b}
  & \includegraphics[width=0.2\textwidth,valign=c]{example-image-c} \\
\bottomrule
\end{tabular}

\caption{Example.}
\label{fig:BlockComparison_MatDist_pa=12}

\end{figure}

\end{document}

您也不需要\bgroup\egroup,因为在 内进行的设置figure是局部的。例如, 的值\aboverulesep将在 之后恢复\end{figure}

在此处输入图片描述

相关内容