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 want to do a table with some columns (9) but I want the first 2 columns on the first row to be empty. I can't seem to be able to close the top of my table the way I do it.

\begin{tabular}{|c|c||c|c|c||c|c|c||c|}
\multicolumn{2}{c||}{}&\multicolumn{3}{c||}{Dimensions finies}&\multicolumn{3}{|c||}{   Dimensions brutes}\\
\hline
Identification & Qté & Long.&Larg.& Épais.& Long.& Larg.& Épais. &PMP\\
\hline
Dessus & $1$ & $46$ & $28$ & $6/4$& & & & \\
\hline
Pattes & $4$ & $37\sfrac{1}{2}$ & $3$ & $2$& & & & \\
\hline
\end{tabular}
share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

You can use \cline{i-j} to draw a line from column i to column j; however, I would like to suggest you the booktabs package to design your tables; your table with and without booktabs:

\documentclass{article}
\usepackage{booktabs}
\usepackage{array}

\begin{document}

\noindent\begin{tabular}{*{9}{|c}|}
\cline{3-8}
\multicolumn{2}{c}{}&\multicolumn{3}{||c||}{Dimensions finies}&\multicolumn{3}{|c||}{   Dimensions brutes}\\
\hline
Identification & Qté & Long.&Larg.& Épais.& Long.& Larg.& Épais. &PMP\\
\hline
Dessus & $1$ & $46$ & $28$ & $6/4$& & & & \\
\hline
Pattes & $4$ & $37\frac{1}{2}$ & $3$ & $2$& & & & \\
\hline
\end{tabular}

\vspace{20pt}

\noindent\begin{tabular}{@{}c*{7}{c}c@{}}
\toprule
& &\multicolumn{3}{c}{Dimensions finies}&\multicolumn{3}{c}{Dimensions brutes}\\
\cmidrule(r){1-2}\cmidrule(lr){3-5}\cmidrule(lr){6-8}\cmidrule(l){9-9}
Identification & Qté & Long.&Larg.& Épais.& Long.& Larg.& Épais. &PMP\\
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(lr){3-3}
\cmidrule(lr){4-4}\cmidrule(lr){5-5}\cmidrule(lr){6-6}
\cmidrule(lr){7-7}\cmidrule(lr){8-8}\cmidrule(l){9-9}
Dessus & $1$ & $46$ & $28$ & $6/4$& & & & \\
\midrule
Pattes & $4$ & $37\frac{1}{2}$ & $3$ & $2$& & & & \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

As you can see, there's really no need for the vertical rules and the table now looks much better than before.

share|improve this answer
    
Thanks, I'll look up the booktabs package. Any way to lengthen a bit the \cline, as you see there is space on the left side? –  Jean-Sébastien Aug 16 '12 at 23:56
1  
@Jean-Sébastien I've updated my answer. –  Gonzalo Medina Aug 17 '12 at 0:33
add comment

For completeness, here's how to adequately align the vertical and horizontal rules in your code snippet:

enter image description here

\documentclass[twocolumn]{article}
\usepackage{xfrac}% http://ctan.org/pkg/xfrac
\usepackage[utf8]{inputenc}% http://ctan.org/pkg/inputenc
\begin{document}
\begin{tabular}{|c|cc|c|c||c|c|c||c|}
  \cline{3-8}
  \multicolumn{2}{c}{} & \multicolumn{3}{||c||}{Dimensions finies} & \multicolumn{3}{c||}{Dimensions brutes} \\
  \hline
  Identification & Qté & \multicolumn{1}{||c|}{Long.} & Larg. & Épais. & Long.& Larg.& Épais. & PMP \\
  \hline
  Dessus & $1$ & \multicolumn{1}{||c|}{$46$} & $28$ & $6/4$& & & & \\
  \hline
  Pattes & $4$ & \multicolumn{1}{||c|}{$37\sfrac{1}{2}$} & $3$ & $2$& & & & \\
  \hline
\end{tabular}
\end{document}

The double vertical rule was added to the beginning of the third column rather than a shared vertical between the second and third.


Alternatively, consider this representation that uses a 1pt vertical rule (as opposed to two .4pt vertical rules with some gap):

enter image description here

\documentclass[twocolumn]{article}
\usepackage{xfrac}% http://ctan.org/pkg/xfrac
\usepackage{array}% http://ctan.org/pkg/array
\usepackage[utf8]{inputenc}% http://ctan.org/pkg/inputenc
\begin{document}
\begin{tabular}{|c|c!{\vrule width 1pt}c|c|c!{\vrule width 1pt}c|c|c!{\vrule width 1pt}c|}
  \cline{3-8}
  \multicolumn{2}{c!{\vrule width 1pt}}{} & 
  \multicolumn{3}{c!{\vrule width 1pt}}{Dimensions finies} & 
    \multicolumn{3}{c!{\vrule width 1pt}}{Dimensions brutes} \\
  \hline
  Identification & Qté & Long. & Larg. & Épais. & Long.& Larg.& Épais. & PMP \\
  \hline
  Dessus & $1$ & $46$ & $28$ & $6/4$& & & & \\
  \hline
  Pattes & $4$ & $37\sfrac{1}{2}$ & $3$ & $2$& & & & \\
  \hline
\end{tabular}
\end{document}
share|improve this answer
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.