[Tex/LaTex] How to draw a horizontal line spanning only some of the table cells

rulestables

In a table, how can I draw a horizontal line that goes only through some of the cells? I mean a line like the one in the Foo and in the Bar area of this table:

+----+-----+
|Foo |1 |2 |
|    |1 |2 |
|    +--+--+
|    |1 |2 |
|    |1 |2 |
+----+-----+
|Bar |1 |2 |
|    |1 |2 |
|    +--+--+
|    |1 |2 |
|    |1 |2 |
+----+--+--+

Best Answer

Instead of nested tables as xport_is_sleeping suggested, you can also use \cline{2-3} which draws a partial line starting on column 2 and ending on column 3 and use \multirow to center the words Foo and Bar on the lines if that's what you want:

alt text

\documentclass{article}
\usepackage{array,multirow}
\begin{document}
\begin{tabular}{|c|cc|}\hline
\multirow{4}{*}{Foo} & 1 & 2 \\
    & 1 & 2 \\\cline{2-3}
    & 1 & 2 \\
    & 1 & 2 \\\hline
\multirow{4}{*}{Bar} & 1 & 2 \\
    & 1 & 2 \\\cline{2-3}
    & 1 & 2 \\
    & 1 & 2 \\\hline
\end{tabular}
\end{document}

When making tables, you should also always use the array package which offers various additional features and improvements (most notably at the vertical and horizontal lines joins).