# How to merge cells vertically

Is it possible to create a table like this one?

The usual structure of tables I use looks like this:

\begin{table}[H]
\begin{tabular}{lll}
\hline
\hline
\ttfamily xxx & \ttfamily xxx & \ttfamily xxx \\
\hline
\end{tabular}
\vspace{ - 05 mm}
\caption{xxx}
\label{tab:xxx}
\end{table}

-
Isn't what you want actually to merge cells vertically? –  Vivi Sep 17 '12 at 20:07
Ahh, you are right. Just changed. :D –  eualin Sep 17 '12 at 20:09
You may want to check the examples in wikibooks on merging cells. You may want to use the multirow command for cells spanning multiple rows. –  mythealias Sep 17 '12 at 20:57

You can use multirow If you are trying to align four rows of a particular column, put

\multirow{4}{*}{XXX}


in the first row and leave three subsequent rows below empty like

\multirow{4}{*}{XXX} &
&
&
&


Then the contents are vertically aligned.

\documentclass[a4paper,12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{multirow}

\begin{document}
\begin{table}[h]
\centering
\begin{tabular}{lll}
\hline
\multirow{4}{*}{XXX} & \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX} \\\cline{2-3}
& \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX}
\\\cline{2-3}
& \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX}
\\\cline{2-3}
& \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX}
\\\hline
\ttfamily xxx & \ttfamily xxx & \ttfamily xxx \\
\hline
\end{tabular}
%     \vspace{ - 05 mm}
\caption{xxx}
\label{tab:xxx}
\end{table}

\end{document}


-

Here is a stripped down version of what you want (I had to get rid of a few things because I didn't know which packages you had loaded and the code wouldn't compile without them):

\begin{table}[h]
\begin{tabular}{lll}
\hline
\multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX} & \multicolumn{1}{l}{XXX} \\\cline{2-3}
\ttfamily xxx & \ttfamily xxx & \ttfamily xxx \\
\hline
\end{tabular}
\vspace{ -05mm}
\caption{xxx}
\label{tab:xxx}
\end{table}


In summary, what you need is the command \cline{2-3} at the end of a line to indicate where the line should start and finish (in this case it starts at column 2 and finishes at column 3).

-
OK. I think I got it. But how to align the left-hand side element to the centre? –  eualin Sep 17 '12 at 20:31
Align it vertically to the centre you mean? This construct doesn't give a way to do that. I think you can tweak it to give the result you want, but in the example you gave this doesn't even make sense. I suggest you give a better example in your question (more rows so that alignment is an issue), but to be honest, I am pretty sure there is a way to actually merge the cells, instead of just dealing with the lines, I just don't know it. –  Vivi Sep 17 '12 at 20:50