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.

Is there any easy way to obtain something like this in LaTeX?

http://img15.hostingpics.net/pics/574631tab.png

My guess was to try to make the first and third cell of the first row invisible, but then I lose the right and left border of the Main 1 cell... I didn't find any package that would allow to do this easily, so if you have any package name or trick (maybe it's fairly simple using standard LaTeX tables, I don't know), it would greatly help me.

share|improve this question
add comment

1 Answer

No need of additional packages:

\documentclass{article}

\begin{document}

\begin{tabular}{*{5}{|c}|}
\cline{2-4}
\multicolumn{1}{c}{} & \multicolumn{3}{|c|}{Main 1} \\
\hline
Title 1 & Title 2 & Title 3 & Title 4 & Title 5 \\
\hline
& & & & \\
\hline
& & & & \\
\hline
& & & & \\
\hline
\end{tabular}

\end{document}

enter image description here

The first row could have been written also in the following way (so as to have the complete number of declared columns):

\multicolumn{1}{c}{} & \multicolumn{3}{|c|}{Main 1} & \multicolumn{1}{c}{} \\

If you want to improve the quality of your table, then the booktabs package could be of interest (vertical rules won't now be allowed):

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{@{}c*{3}{c}c@{}}
\toprule
& \multicolumn{3}{c}{Main 1} & \\
\cmidrule(lr){2-4}
Title 1 & Title 2 & Title 3 & Title 4 & Title 5 \\
\cmidrule(r){1-1}\cmidrule(lr){2-2}\cmidrule(lr){3-3}\cmidrule(lr){4-4}\cmidrule(l){5-5}
& & & & \\
\midrule
& & & & \\
\midrule
& & & & \\
\bottomrule
\end{tabular}

\end{document}

enter image description here

Depending on the table contents, even some or all of the \midrules could be suppressed.

share|improve this answer
    
Wouldn't it be "cleaner" to add another & \multicolumn{1}{c}{} for the first row? So: \multicolumn{1}{c}{} & \multicolumn{3}{|c|}{Main 1} & \multicolumn{1}{c}{} \\ –  doncherry Oct 3 '12 at 21:55
    
@doncherry if it were absolutely necessary, yes, but in this case there's really no need to add it. –  Gonzalo Medina Oct 3 '12 at 22:00
    
Well, it seems to work fine without it, but in terms of semantic completeness, it just feels wrong to me to have one row with only four rows, technically. –  doncherry Oct 3 '12 at 22:13
    
@doncherry I know what you mean; I'll add a note then. –  Gonzalo Medina Oct 3 '12 at 22:16
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.