简体   繁体   中英

Merging cells in LaTeX tables

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

The command you want is \\cline{ij} 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}

Well, to not address your question, I'll note that many authorities suggest minimizing the amount of internal ink in your table (ie ditch the \\hline s between ordinary rows), and using something line the last figure here .

If you are not constrained by some tightly defined style guide, this would be my solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM