How can I create a table such as following: I do not know how can I have A and B in the middle of four rows ?
1 Answer
How about:
\usepackage{multirow}
\begin{document}
\begin{table}[h]
\begin{tabular}{|l|l|l|l|l|}
\hline
X & xx & x & x & x \\ \hline
\multirow{4}{*}{A} & x & x & x & x \\ \cline{2-5}
& x & x & x & x \\ \cline{2-5}
& x & x & x & x \\ \cline{2-5}
& x & x & x & x \\ \hline
\multirow{4}{*}{B} & x & x & x & x \\ \cline{2-5}
& x & x & x & x \\ \cline{2-5}
& x & x & x & x \\ \cline{2-5}
& x & x & x & x \\ \hline
\end{tabular}
\end{table}
\end{document}
Edit: If you don't like the lines:
\begin{table}[h]
\begin{tabular}{lllll}
X & xx & x & x & x \\ \hline
\multirow{4}{*}{A} & x & x & x & x \\
& x & x & x & x \\
& x & x & x & x \\
& x & x & x & x \\[1ex]
\multirow{4}{*}{B} & x & x & x & x \\
& x & x & x & x \\
& x & x & x & x \\
& x & x & x & x
\end{tabular}
\end{table}
-
-
Well, they can be very easily removed from the code provided (see my edit above). I thought the focus of the question was more about having "A and B in the middle of four rows".– roschuJul 24, 2014 at 13:56
-
1In my view, all those extra lines simply create clutter and thus actually make it harder to find the two crucial parts, which are the
\multirow
instructions.– MicoJul 24, 2014 at 13:58 -
-
1Much better... :-) I've taken the liberty of editing your second example to make it approximate the OP's sketch more closely.– MicoJul 24, 2014 at 13:59
multirow
package is done for that. It may require some adjustment.