使用多行和多列作为表格

使用多行和多列作为表格

使用多行和多列,如何在 Latex 中生成下表?

必填表

我目前得到的:

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}{|l|l|l|l|l|l|l|l|l|l|l|l|}\hline
  \multirow{1}{*}{Test}  &  & Image 1 & I2 & I3 & I4 & I5 & I6 & I7 & I8 & I9 & I10 \\ \cline{1-12}
  \multirow{2}{*}{1}
  & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\ \cline{1-12}
  \multirow{2}{*}{2}
  & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\ \cline{1-12}
  \multirow{2}{*}{3}
  & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\ \cline{1-12}
  \multirow{2}{*}{4}
  & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\ \cline{1-12}
  \multirow{2}{*}{5}
  & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\ \cline{1-12}
  \multirow{2}{*}{6}
  & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\ \cline{1-12}
  \multirow{2}{*}{7}
  & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\ \cline{1-12}
\end{tabular}
\end{document}

答案1

\documentclass[10pt,letterpaper]{article}

\usepackage{multirow}
\usepackage{hhline}
\usepackage{ctable}
\begin{document}
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|}\hline\hline\omit\vline
        \strut\multirow{1}{*}{ Test\phantom{\LARGE H}} 
        & \multirow{1}{*}{} & Image 1\phantom{\LARGE H}%
 & I2 & I3 & I4 & I5 & I6 & I7 & I8%
     & I9 & I10 \\ \hline\hline
        \multirow{2}{*}{1}
        & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\%
     \cline{2-12}
        & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\%
     \specialrule{.2em}{.1em}{.1em}
        \multirow{2}{*}{2}
        & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\%
          \cline{2-12}
        & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\%
          \specialrule{.2em}{.1em}{.1em}
        \multirow{2}{*}{3}
        & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\%
          \cline{2-12}
        & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\%
          \specialrule{.2em}{.1em}{.1em}
        \multirow{2}{*}{4}
        & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\%
          \cline{2-12}
        & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\%
          \specialrule{.2em}{.1em}{.1em}
        \multirow{2}{*}{5}
        & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\%
          \cline{2-12}
        & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\%
          \specialrule{.2em}{.1em}{.1em}
        \multirow{2}{*}{6}
        & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\%
          \cline{2-12}
        & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\%
          \specialrule{.2em}{.1em}{.1em}
        \multirow{2}{*}{7}
        & \multirow{1}{*}{A} & x & x & x & x & x & x & x & x & x & x \\%
          \cline{2-12}
        & \multirow{1}{*}{B} & x & x & x & x & x & x & x & x & x & x \\%
              \hline\hline
    \end{tabular}
\end{document}

![在此处输入图片描述

答案2

要使标签“测试”跨越两列,请写入\multicolumn{2}{|c|}{Test}

为了减少代码混乱,我建议您将所有七个实例替换为\multirow{1}{*}{A}A并且还将所有 替换为\multirow{1}{*}{B}B并且,请写\hline而不是\cline{1-12}

假设第 3 列至第 12 列的单元格最终将填充比 X 更多的材料,则几乎肯定需要将表格“横向”排版,即在横向模式下,在单独的页面上。

说实话,我不会费心复制您发布的屏幕截图中的双线外观。相反,我会努力去除所有垂直线和大多数水平线。

\documentclass{article}
\usepackage{multirow,rotating}
\begin{document}

\begin{sidewaystable}  % if necesssary
\renewcommand\arraystretch{1.25}
\centering
\begin{tabular}{|*{12}{c|}}
\hline
\multicolumn{2}{|c|}{Test}  
    & Image 1 & Image 2 & Image 3 & Image 4 & Image 5 
    & Image 6 & Image 7 & Image 8 & Image 9 & Image 10 \\ \hline
\multirow{2}{*}{1}
  & A & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & B & x & x & x & x & x & x & x & x & x & x \\ \hline
\multirow{2}{*}{2}
  & A & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & B & x & x & x & x & x & x & x & x & x & x \\ \hline
\multirow{2}{*}{3}
  & A & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & B & x & x & x & x & x & x & x & x & x & x \\ \hline
\multirow{2}{*}{4}
  & A & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & B & x & x & x & x & x & x & x & x & x & x \\ \hline
\multirow{2}{*}{5}
  & A & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & B & x & x & x & x & x & x & x & x & x & x \\ \hline
\multirow{2}{*}{6}
  & A & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & B & x & x & x & x & x & x & x & x & x & x \\ \hline
\multirow{2}{*}{7}
  & A & x & x & x & x & x & x & x & x & x & x \\ \cline{2-12}
  & B & x & x & x & x & x & x & x & x & x & x \\ \hline
\end{tabular}
\end{sidewaystable} % if necessary
\end{document}

相关内容