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:
Best Answer
You can do this using
\multicolumn
which has a width of1
column; it may seem a little funny, but it's a standard way to fix this.I've used
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 yourtabular
declaration which didn't harm things, but I've removed it.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
which removes all the vertical lines, then you get
See also Why not use vertical lines ('|') in a tabular?
Another idea (thanks @doncherry, @Qrrbrbirlbel) is to right align the columns and insert
<{\,\%}
between columns2
and3
; this requires thearray
package; note that this trick adds a%
to each row in that column, so I've had to use themulticolumn
trick again to remove it from the first row.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) theS
column type.