Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}

    \addlinespace
    \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}
share|improve this question
    
@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
1  
@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
show 2 more comments

migrated from stackoverflow.com Apr 14 '11 at 12:29

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

2 Answers

up vote 2 down vote accepted

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.

Answer Below-----------------

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}
share|improve this answer
    
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
add comment

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

share|improve this answer
    
@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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.