[Tex/LaTex] Row with invisible cells

formattingtables

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.

Best 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.