Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging cells in LaTeX tables

Tags:

latex

pdflatex

I have a very simple table:

\begin{table}[t]
\begin{tabular}{|c||c|c|c|}
\hline
\multirow{2}{*}{Implementation}         & Test 1  & Test2  &  Test3    \\\hline
                                        & \multicolumn{3}{|c|}{results}   \\\hline\hline
\end{tabular}
\end{table}

It works almost "perfect", the only problem that I have is that the hline still goes through the first two cells that I have merged. Basically, it looks like this

"-------------------------------------------------"
"|                | Test 1 | Test 2 | Test 3 |"
" ----Implementation-------------------------------"
"|                |     results      |"  
"-------------------------------------------------"

However, it should like this:

"-------------------------------------------------" 
"|               | Test 1 | Test 2 | Test 3 |"
"   Implementation    ---------------------------"
"|               |      results     |"   
"-------------------------------------------------"

Anyone an idea how to get rid of the line in the first column?

Thanks

like image 749
John Avatar asked Feb 08 '10 19:02

John


People also ask

How do you merge cells in a table?

Merge cellsIn the table, drag the pointer across the cells that you want to merge. Click the Layout tab. In the Merge group, click Merge Cells.

How do you do multicolumn in LaTeX?

LaTeX Multiple Columns Text with two or double columns can be created by passing the parameter \twocolumn to the document class statement. If you want to create a document with more than two columns, use the package multicol, which has a set of commands for the same.


1 Answers

The command you want is \cline{i-j} which lets you draw a row divider across only certain columns. See http://www.giss.nasa.gov/tools/latex/ltx-214.html for details.

In particular, you'll want to use \cline{2-4} to draw a horizontal line across just the columns you mentioned. Here's your code with the one change:

\begin{table}[t]
\begin{tabular}{|c||c|c|c|}
\hline
\multirow{2}{*}{Implementation}         & Test 1  & Test2  &  Test3    \\\cline{2-4}
                                        & \multicolumn{3}{|c|}{results}   \\\hline\hline
\end{tabular}
\end{table}
like image 179
David Underhill Avatar answered Nov 04 '22 19:11

David Underhill