0

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 ?enter image description here

2

1 Answer 1

1

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}

enter image description here

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}
5
  • Is the OP asking for all those horizontal and vertical lines?
    – Mico
    Jul 24, 2014 at 13:45
  • 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".
    – roschu
    Jul 24, 2014 at 13:56
  • 1
    In 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.
    – Mico
    Jul 24, 2014 at 13:58
  • Check my edit above.
    – roschu
    Jul 24, 2014 at 13:59
  • 1
    Much better... :-) I've taken the liberty of editing your second example to make it approximate the OP's sketch more closely.
    – Mico
    Jul 24, 2014 at 13:59

Not the answer you're looking for? Browse other questions tagged .