[Tex/LaTex] multicolumn table in Beamer

beamermulticolumntables

I'm new to beamer. I want to have table in my presentation same as in my latex document.

\begin{center}
\begin{tabular}{cc|c|c|}
\cline{3-4}
& & \multicolumn{2}{|c|}{Condition (Gold standard)}\\
\cline{3-4}
& & True & False \\
\hline
\multicolumn{1}{ |c| }{\multirow{2}{*}{Test outcome}}& \multicolumn{1}{ |c| }{Positive} & True Positive \cellcolor{green} & False Positive\cellcolor{red}\\
\cline{2-4}
\multicolumn{1}{ |c| }{} & \multicolumn{1}{ |c| }{Negative} & False Negative\cellcolor{red} & True Negative \cellcolor{green}\\
\hline
\end{tabular}
\end{center}

This is the table, but the multicolumn command is not working in beamer. Thanks for your help!

Best Answer

You need to pass the [table] option to beamer (which will then pass it to the xcolor package, which it loads).

\documentclass[table]{beamer}
\usepackage{multirow}

\begin{document}
\begin{frame}
\frametitle{}
\begin{center}
\begin{tabular}{cc|c|c|}
\cline{3-4}
& & \multicolumn{2}{|c|}{Condition (Gold standard)}\\
\cline{3-4}
& & True & False \\
\hline
\multicolumn{1}{ |c| }{\multirow{2}{*}{Test outcome}}& 
  \multicolumn{1}{ |c| }{Positive} & True Positive \cellcolor{green} & 
  False Positive\cellcolor{red}\\
\cline{2-4}
\multicolumn{1}{ |c| }{} & \multicolumn{1}{ |c| }{Negative} & 
  False Negative\cellcolor{red} & True Negative \cellcolor{green}\\
\hline
\end{tabular}
\end{center}\end{frame}

\end{document}

output of code

Related Question