# How can I create a LaTeX table with merged cells in 2nd column or later

I wish to generate a LaTeX table with merged cells in the 2nd column. Any examples I have seen so far have merged cells in the 1st column. The text also needs to wrap with in the cell.

(couldn't post pictures yet!) Basically , I have 3 columns, 15 rows.

column 1 sample id, column 2 time, column 3 remarks

col1 rows 1-15 unmerged (normal)

col2 rows 1-7 unmerged (normal)

col3 rows 5-7 merged, wrapped text

col3 rows 8-12 merged wrapped text

col2 rows 8-13 merged, need to wrap text

etc.

The resulting implementation using excel2latex (booktabs, multirow packages) gives the following code:

\begin{table}

\centering

\begin{tabular}{rrr}

\toprule
Sample ID & Time [s] & Remarks \\
\midrule
1     & \multicolumn{1}{c}{50} &  \\
2     & \multicolumn{1}{c}{100} &  \\
3     & \multicolumn{1}{c}{150} &  \\
4     & \multicolumn{1}{c}{200} &  \\
5     & \multicolumn{1}{c}{250} & \multicolumn{1}{c}{\multirow{3}[0]{*}{Sampled from different area of the tank}} \\
6     & \multicolumn{1}{c}{250} & \multicolumn{1}{c}{} \\
7     & \multicolumn{1}{c}{250} & \multicolumn{1}{c}{} \\
a     & \multicolumn{1}{c}{\multirow{6}[0]{*}{No times recorded for this section but it is known that there is a constant time gap between samples}} & \multicolumn{1}{c}{\multirow{5}[0]{*}{No discernible difference samples a-e}} \\
b     & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} \\
c     & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} \\
d     & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} \\
e     & \multicolumn{1}{c}{} & \multicolumn{1}{c}{} \\
f     & \multicolumn{1}{c}{} & viscous \\
g     & Short time & odourless \\
h     & Long time & strong acrid odour, high viscosity \\
\bottomrule
\end{tabular}%
\end{table}

-

## migrated from stackoverflow.comApr 14 '11 at 12:29

This question came from our site for professional and enthusiast programmers.

@Lesser I answered your question –  sawa Apr 13 '11 at 23:44
@Lesser I removed my answer because there was no response from you. –  sawa Apr 14 '11 at 4:37
@sawa: that is a stupid "reason" for removing an answer. –  Svante Apr 14 '11 at 8:55
@JSBangs don’t comment please, since this will result in cross-posts. Instead, just flag for moderator attention. –  Konrad Rudolph Apr 14 '11 at 9:12
What exactly is the question here? You seem to have given the answer yourself. Whether the cells are merged in the first column or later makes absolutely no difference. –  Konrad Rudolph Apr 14 '11 at 9:13

Okay, following the request, I am reposting the answer. You need to understand that I spent some time answering this. The acceptance rate shown under each person is to show people whether it is likely that the questioner appropriately responds, and if it is too low, it means you ignore the answers, and people would not want to answer to that person any more.

Probably this is what you want. Adjust the parameters according to your choice:

\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{tabular}
{|r|c|c|}
\hline
\multicolumn{1}{|c|}{Sample ID}&
\multicolumn{1}{|c}{Time [s]}&
\multicolumn{1}{|c|}{Remarks}
\\\hline\hline
1 &50 & \\\hline
2 &100 & \\\hline
3 &150 & \\\hline
4 &200 & \\\hline
5 &250 &
\multirow{3}{*}{\parbox{2in}{Sampled from different area of the tank}}
\\\cline{1-2}
6 &250 & \\\cline{1-2}
7 &250 & \\\hline
a &
\multirow{6}{*}
{\parbox{2in}{No times recorded for this section but it is known that there is a constant time gap between samples}}
&
\multirow{5}{*}{No discernible difference samples a-e} \\\cline{1-1}
b & & \\\cline{1-1}
c & & \\\cline{1-1}
d & & \\\cline{1-1}
e & & \\\cline{1-1}\cline{3-3}
f & & viscous \\\hline
g & Short time & odourless \\\hline
h & Long time & strong acrid odour, high viscosity \\
\hline
\end{tabular}
\end{document}

-
Thanks, works a treat. Much appreciated. Now that our working time zones overlap, I can respond within an acceptable time frame. Once again, I do appreciate your help and suggestions. –  Leeser Apr 14 '11 at 16:06
Helpful, Thanks! –  Newb Jul 11 at 21:19

http://maksim.sorokin.dk/it/2010/05/22/multirow-and-multicolumn-spanning-in-latex/

Has examples for multicolumn, and multirow. For wrapping, look at the p attribute.

http://en.wikibooks.org/wiki/LaTeX/Tables#Text_wrapping_in_tables

-
@thouis: Thanks for this, I just rearranged the Leeds United team sheet and it worked. I think it was an overcomplication by excel2latex and LaTeXing by hand works...cheers –  Leeser Apr 14 '11 at 9:38