I am trying to draw a table where some lines have (vertical) borders and some lines don't. I couldn't find a satisfying way to do this.
Horizontal borders are not the problem obviously, since I can decide where I need a \hline
, but the vertical ones seem to be fixed in the parameter of the whole tabular
environment.
The best I could find was using multicolumn
, but I guess that's not the proper way to do it, since its real purpose is to merge cells.
Here is what I've done so far:
\begin{tabular}{ cccccccc }
\hline
\multicolumn{1}{|c|}{7} &
\multicolumn{1}{|c|}{16} &
\multicolumn{1}{|c|}{3} &
\multicolumn{1}{|c|}{-1} &
\multicolumn{1}{|c|}{9} &
\multicolumn{1}{|c|}{32} &
\multicolumn{1}{|c|}{4} &
\multicolumn{1}{|c|}{2}\\
\hline
0 & 1 & 2 & 3 & 4 & 5 & 6 & 7\\
\end{tabular}
This example code does produce the layout I need, but I'm sure that's not how it should be done.
tl;dr: I want to produce a table where the first line has horizontal and vertical borders, while the second line doesn't have any borders at all.
\multicolumn{1}{|c|}{...}
statements should have only one, not two, vertical bars. E.g, the first statement could be\multicolumn{1}{|c|}{7}
, and the remaining seven should be of the form\multicolumn{1}{c|}{...}
. This issue becomes very evident if you load thearray
package -- or if you load a package (such astabularx
) that, in turn, loads thearray
package.