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.

This is my code

\begin{tabular}{|c|c|}
\hline
Genre&Prénom\\\hline
Humain&Aragorn\\\hline
\multirow{4}{*}{Hobbit}&Frodon\\\cline{2-2}
&Sam\\\cline{2-2}
&Peregrin\\\cline{2-2}
&Meriadoc\\\hline
Elfe&Legolas\\\hline
\end{tabular}

How can i add a third column like the second column?

share|improve this question
6  
\begin{tabular}{|c|c|c|} seems to be quite natural, isn't it? –  egreg Nov 14 '12 at 16:05
1  
@egreg and \cline{2-3} instead of \cline{2-2}. –  Qrrbrbirlbel Nov 14 '12 at 16:25
    
thank you for answer :) –  researcher Nov 14 '12 at 16:37
    
As it stands, this is very localised so I've closed. –  Joseph Wright Nov 14 '12 at 17:55
add comment

closed as too localized by Joseph Wright Nov 14 '12 at 17:54

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 2 down vote accepted

I want to show you three different solutions for your table:

table.tex

\documentclass{article}

\usepackage{booktabs} % for nice lines
\usepackage{siunitx}  % nice numbers and units and 'S' in table
\usepackage{multirow} % enable \multirow command

\begin{document}
short answer to your question:\\
\begin{tabular}{|c|c|S|}
\hline
Genre & Name & {Weight}\\\hline
Humain & Aragorn & 102 \\\hline
\multirow{4}{*}{Hobbit}&Frodon & 32.1\\\cline{2-3}
    &Sam & 3.2 \\\cline{2-3}
    &Peregrin & 2.232\\\cline{2-3}
    &Meriadoc & 23 \\\hline
Elfe&Legolas & 34.5 \\\hline
\end{tabular}\\[1cm]

You can also use the power of booktabs and siunitx:\\
\begin{tabular}[ht]{l c S} % alignment l = left, c = centre, S = at decimal - needs siunitx
\toprule
Genre&Name& {Weight}\\  % protect non numbers with {} in S columns
\midrule
Elfe&Legolas & 34.5\\
Dwarf&Peter & 103.31\\
\bottomrule
\end{tabular}\\[1cm]

And combine that with your table:\\
\begin{tabular}{c c S}
\toprule
Genre & Name & {Weight}\\\midrule
Humain & Aragorn & 102 \\\midrule
\multirow{4}{*}{Hobbit}&Frodon & 32.1\\\cline{2-3}
    &Sam & 3.2 \\\cline{2-3}
    &Peregrin & 2.232\\\cline{2-3}
    &Meriadoc & 23 \\\midrule
Elfe&Legolas & 34.5 \\
\bottomrule
\end{tabular}

\end{document}

3 tables

share|improve this answer
    
Thank you so much for explanation :) –  researcher Nov 14 '12 at 20:51
add comment

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