I am trying to sort out a multicolumn table using tabular. Since I am not so experienced in latex, I've relied on tablesgenerator.com to generate the code, which is:
% Please add the following required packages to your document preamble:
% \usepackage{booktabs}
% \usepackage{multirow}
% \usepackage[table,xcdraw]{xcolor}
% If you use beamer only pass "xcolor=table" option, i.e. \documentclass[xcolor=table]{beamer}
\begin{table}[]
\begin{tabular}{@{}cc
>{\columncolor[HTML]{000000}}c
>{\columncolor[HTML]{000000}}c @{}}
\multicolumn{2}{c}{} & \multicolumn{2}{c}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} Party Labels}} \\
\multicolumn{2}{c}{\multirow{-2}{*}{}} & {\color[HTML]{FFFFFF} High stability} & {\color[HTML]{FFFFFF} Low stability} \\
\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} } & \cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} High stability} & \cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} Stable systems} & \cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} Ephemeral parties} \\
\multirow{-2}{*}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} \begin{tabular}[c]{@{}c@{}}Programmatic\\ positions\end{tabular}}} & \cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} Low stability} & \cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} Empty labels} & \cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} Unstable systems}
\end{tabular}
\end{table}
This results in the following table:
This is more or less what I need, but for some reason, the cell size of the last cell in the first row (party labels) is a bit shorter than the cells in the following rows. It's a bit annoying because it ruins the layout of the table.
Any ideas how to get equal widths for the cells in the last column?
Thanks!
PS: If I use the option suggested by the website \usepackage[table,xcdraw]{xcolor}
it throws an error of conflicting options, so I set it up as \usepackage[table]{xcolor}
. I use all this with beamer
.
UPDATE - compilable/reproducible code:
\documentclass[xcolor=table]{beamer}
\mode<presentation> {
\usetheme{Madrid}}
\usepackage{booktabs} % Allows the use of \toprule, \midrule and \bottomrule in tables
\usepackage{multirow}
\usepackage[table]{xcolor}
\begin{document}
\begin{frame}
\begin{table}[]
\begin{tabular}{@{}cc
>{\columncolor[HTML]{000000}}c
>{\columncolor[HTML]{000000}}c @{}}
\multicolumn{2}{c}{} & \multicolumn{2}{c}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} Party Labels}} \\
\multicolumn{2}{c}{\multirow{-2}{*}{}} & {\color[HTML]{FFFFFF} High stability} & {\color[HTML]{FFFFFF} Low stability} \\
\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} } & \cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} High stability} & \cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} Stable systems} & \cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} Ephemeral parties} \\
\multirow{-2}{*}{\cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} \begin{tabular}[c]{@{}c@{}}Programmatic\\ positions\end{tabular}}} & \cellcolor[HTML]{000000}{\color[HTML]{FFFFFF} Low stability} & \cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} Empty labels} & \cellcolor[HTML]{EFEFEF}{\color[HTML]{000000} Unstable systems}
\end{tabular}
\end{table}
\end{frame}
\end{document}