8

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.

12

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.

  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy