There was a peculiar LaTeX problem that I encountered recently with the
tabular environment. Controlling the appearance of vertical lines between columns can be a real problem. It was particularly baffling me because although there is a
\cline command to draw horizontal lines spanning between a few columns, there was no corresponding command to draw a vertical line that spans only a few rows. By default, when you create a tabular, you can draw vertical lines between columns, but only if they span the entire length of the table.
You can see what I mean, by looking at this screenshot.

As you can see, drawing such a table is not straightforward. It's easy to draw those horizontal lines, but not at all possible to draw vertical lines which don't span the entire table. There was a
workaround which I found after asking for help at
CQF.info. The solution was to use the
\multicolumn command.
Here is the code which produces that effect:
\begin{tabular}{lll}
& X & Y \\
\cline{2-3}
\multicolumn{1}{l|}{Number of bulbs used} & \multicolumn{1}{l|}{100}
& \multicolumn{1}{l|}{100} \\
\cline{2-3}
\multicolumn{1}{l|}{Average life (hrs)} & \multicolumn{1}{l|}{1300} & \multicolumn{1}{l|}{1248} \\
\cline{2-3}
\multicolumn{1}{l|}{Standard deviation (hrs)} & \multicolumn{1}{l|}{82} & \multicolumn{1}{l|}{93} \\
\cline{2-3}
\end{tabular}
It's fair to say that LaTeX is not particularly strong when handling tabular material and so you have a lot of additional packages which provide environments such as
supertabular,
tabularx,
longtable and so on. However I am glad that I could resolve this particular issue, although the code involved is much longer since you have to use the
\multicolumn command repeatedly. A better solution would definitely be appreciated.
3 comment(s)
Leave a comment »\multicolumn{1}{l}{} & \multicolumn{1}{l}{X} & \multicolumn{1}{l}{Y} \\
\cline{2-3}
Number of bulbs used & 100 & 100 \\
\cline{2-3}
Average life (hrs) & 1300 & 1248 \\
\cline{2-3}
Standard deviation (hrs) & 82 & 93 \\
\cline{2-3}
\end{tabular}
Comment by al2gd (visitor) on 12 Apr 2009 @ 00:13 IST #
Comment by Hari (blog owner) on 12 Apr 2009 @ 20:35 IST #
Comment by Nirmalya Bandyopadhyay (visitor) on 10 Mar 2010 @ 00:33 IST #