# Can we use both tabularx and multirow together?

\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}


Output:

I would like to have merge the cell like in diagram below.

I replaced the \hline with \cline{1-6} and copied some of the other text.

Added changes suggested in a comment.

\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}


• Why is there no X type column in the second tabularx? Also, this table causes an overfull box warning that you might want to address in your answer. You could use \begin{tabularx}{\textwidth}{|X|X|c|c|c|c|} and \multicolumn{2}{|>{\hsize=2\hsize}X|}{\multirow{2}{=}{Longer Text, etc. etc.}} to ensure that the second table is as wide as the textwidth and that too long lines in the merged cell are split into several lines if needed. – leandriis Aug 3 '19 at 7:45
• @leandriis - I knew there was a problem with horizontal line lengths when using hline with multicolumn; thus my answer would be helpful though incomplete. – Rick Smith Aug 3 '19 at 9:19