[Tex/LaTex] Remove vertical lines for table

tables

I am trying to implement the following K-map with a table

  AB
C     00 01 11 10  
    ______________
    0| 1  0  1  0
    1| 0  1  1  0

I implemented it like this:

\begin{table}[htdp]
\begin{center}
\begin{tabular}{c|c|c|c|c|} 
&00 & 01& 11& 10 \\ \hline
0&1&1&1&1\\
1&0&0&0&0\\
\end{tabular}
\end{center}
\label{default}
\end{table}

However on the top row I have vertical lines that I'd like to not see. I went with this approach because if i was to use a one row with the information so that I wouldn't have to worry about aligning the headings. So is there a way I can get the vertical lines not to appear in the heading row?

Best Answer

You can use \multicolumn to override the column specification given in the table format:

\documentclass{article}

\begin{document}

\begin{table}[htdp]
\centering
\caption{A table}
\begin{tabular}{c|c|c|c|c|} 
\multicolumn{1}{c}{} & \multicolumn{1}{c}{00} & \multicolumn{1}{c}{01} & \multicolumn{1}{c}{11} & \multicolumn{1}{c}{10} \\ \hline
0&1&1&1&1\\
1&0&0&0&0\\
\end{tabular}
\label{default}
\end{table}

\end{document}

enter image description here

I used \centering instead of the center environment to prevent extra vertical spacing. Are you sure you need vertical rules at all?

The booktabs package can help you improve your tables; the package documentation gives useful advice on formatting tables. Even in this little example the results are better; compare the vertical spacing of the horizontal rule using booktabs:

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}[htdp]
\centering
\caption{A table}
\begin{tabular}{ccccc} 
& 00 & 01 & 11 & 10 \\ 
\midrule
0 & 1 & 1 & 1 & 1 \\
1 & 0 & 0 & 0 & 0 \\
\end{tabular}
\label{default}
\end{table}

\end{document}

enter image description here