# Delete column line in tabular

I have the following table, but I want to delete the two vertical lines in the GBM and MJD row:

\documentclass{beamer}

\usepackage{booktabs}

\begin{document}

\frame{
\frametitle{Test}
\begin{tabular}{l|l|llr}
\toprule
%\multicolumn{4}{r}{GBM MJD} \\
%\cmidrule(r){1-2}
&  & GBM& MJD\\
\midrule

&1\%  & 1& 2\\
Microsoft & 5\%  &1& 2 \\
&10\%  & 1& 2\\
\midrule
&1\%  & 1& 2\\
Allianz & 5\%  &1& 2 \\
&10\%  & 1& 2\\

\bottomrule
\end{tabular}
}
\end{document}


I want to delete the following lines:

-
Welcome to TeX.SE! – percusse Nov 30 '12 at 16:08

You can do this using \multicolumn which has a width of 1 column; it may seem a little funny, but it's a standard way to fix this.

I've used

\multicolumn{1}{c}{}


in the columns that you didn't want your |. You can read it as a 'multicolumn that spans 1 column, is centered, and has no content'. I also noted that you had an extra column in your tabular declaration which didn't harm things, but I've removed it.

\documentclass{beamer}

\usepackage{booktabs}

\begin{document}

\begin{frame}
\frametitle{Test}

\begin{tabular}{l|l|ll}
\toprule
\multicolumn{1}{c}{}& \multicolumn{1}{c}{} & GBM& MJD\\
\midrule
& 1\%  & 1 & 2 \\
Microsoft & 5\%  & 1 & 2 \\
& 10\% & 1 & 2 \\
\midrule
& 1\%  & 1 & 2 \\
Allianz   & 5\%  & 1 & 2 \\
& 10\% & 1 & 2 \\
\bottomrule
\end{tabular}
\end{frame}

\end{document}


Some folks would recommend avoiding vertical lines altogether (including the author of the booktabs package), but that is personal preference.

Just for reference, if you use

\begin{tabular}{llll}


which removes all the vertical lines, then you get

Another idea (thanks @doncherry, @Qrrbrbirlbel) is to right align the columns and insert <{\,\%} between columns 2 and 3; this requires the array package; note that this trick adds a % to each row in that column, so I've had to use the multicolumn trick again to remove it from the first row.

\documentclass{beamer}
\usepackage{array}
\usepackage{booktabs}

\begin{document}

\begin{frame}
\frametitle{Test}

\begin{tabular}{lr<{\,\%}cc}
\toprule
& \multicolumn{1}{c}{}   & GBM& MJD\\
\midrule
& 1  & 1 & 2 \\
Microsoft & 5  & 1 & 2 \\
& 10 & 1 & 2 \\
\midrule
& 1  & 1 & 2 \\
Allianz   & 5  & 1 & 2 \\
& 10 & 1 & 2 \\
\bottomrule
\end{tabular}
\end{frame}

\end{document}


As you can see, there are lots of details to pay attention to when constructing a tabular! For future reading, you might also like to look at the siunitx which defines (among other useful commands) the S column type.

-
Those folks are right, of course. ;-) – egreg Nov 30 '12 at 16:20
ok, what should I use instead of vertical lines? Thanks a lot for your help! @cmhuges – CoTabSu Nov 30 '12 at 16:26
@CoTabSu you're welcome :) see my update – cmhughes Nov 30 '12 at 16:29
@cmhughes you probably don't need the \multicolumn solution once you get rid of the | in the table definition. Doesn't change the output but makes the code clearer I think. – ArTourter Nov 30 '12 at 17:37
@doncherry @cmhughes <{\,\%} instead of @{\,\%} to get \tabcolsep back. That's the reason GBM looks so close. – Qrrbrbirlbel Nov 30 '12 at 17:53