我们可以同时使用 tabularx 和 multirow 吗?

我们可以同时使用 tabularx 和 multirow 吗?
\documentclass{article}
\usepackage{tabularx}
\usepackage{multirow}
\begin{document}

\begin{table}[h!]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
    \begin{tabularx}{\textwidth}{|c |c |c |X |X |X |}
    \hline
    1 & 2 & 3 & Testing 1 testing 2 Testing 3 & Testing 1 testing 2 Testing 3 & Testing 1 testing 2 Testing 3 \\
         \hline
    A & B & C & Test 1 & Test 1 & Test 1 \\
     &  &  & Test2  & Test2  & Test 2 \\
    \hline
    \end{tabularx}
\caption{tes}
\label{tab:my_label}
\end{table}

\begin{tabular}{|c|c|c|c|c|c|}
                                                                            \hline
   Text A                        &  Text B                       & Test C&  Testing 1 testing 2  3 &  1  2  3 & Testing 1  2  3\\\hline
   \multicolumn{2}{|c|}{\multirow{2}{*}{Longer Text, etc. etc.}} & Test F & Test R & Test O & test Y \\\cline{3-6}
   \multicolumn{2}{|c|}{}                                        & Test G & Test T & Test P & Test O \\\hline
\end{tabular}

\end{document}

输出:

在此处输入图片描述

我希望像下图这样合并单元格。

答案1

我用 替换了\hline\cline{1-6}复制了一些其他文本。

添加了评论中建议的更改。

\documentclass{article}
\usepackage{tabularx}
\usepackage{multirow}
\begin{document}

\begin{table}[h!]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
    \begin{tabularx}{\textwidth}{|c |c |c |X |X |X |}
    \hline
    1 & 2 & 3 & Testing 1 testing 2 Testing 3 & Testing 1 testing 2 Testing 3 & Testing 1 testing 2 Testing 3 \\
         \hline
    A & B & C & Test 1 & Test 1 & Test 1 \\
     &  &  & Test2  & Test2  & Test 2 \\
    \hline
    \end{tabularx}
\caption{tes}
\label{tab:my_label}
\end{table}

\begin{table}[h!]
\setlength\extrarowheight{2pt} % for a ever so slightly more open "look"
\begin{tabularx}{\textwidth}{|X|X|c|c|c|c|}
   \cline{1-6}
   Text A                        &  Text B                       & Test C&  Testing 1 testing 2  3 &  1  2  3 & Testing 1  2  3\\
   \cline{1-6}
   \multicolumn{2}{|>{\hsize=2\hsize}X|}{\multirow{2}{=}{Longer Text, etc. etc.}} & Test F & Test R & Test O & Test Y \\
   \cline{3-6}
   \multicolumn{2}{|c|}{}                                        & Test G & Test T & Test P & Test O \\
   \cline{1-6}
\end{tabularx}
\caption{tabularx with multicolum and multirow}
\end{table}

\end{document}

tabularx 具有多列和多行

相关内容