1

I am using multicol and multirow to add lines in certain spots in a table, and can't get the following lines to connect:

enter image description here

In the bottom left connection:

enter image description here

zooming in even further:

enter image description here

Solutions which keep the -1, +1, and the text within the table are preferable, but not essential.

MWE

\documentclass[11pt]{beamer}
\usepackage{array,multirow,multicol}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\begin{document}
\begin{frame}{Confusion matrices}
\begin{table}[htb]
\centering
\begin{tabular}{@{}cr|C{15mm}|C{15mm}|@{}}
\cline{3-4}
\multirow{2}{*}{\shortstack{Actual\\class}} & $ -1 $ & $ N_\mathrm{TN} $ & $ N_\mathrm{FP} $ \\
\cline{3-4}
& $ +1 $ & $ N_\mathrm{FN} $ & $ N_\mathrm{TP} $ \\
\cline{3-4}
& \multicolumn{1}{c}{} & \multicolumn{1}{c}{$ -1 $} & \multicolumn{1}{c}{$ +1 $} \\
& \multicolumn{1}{c}{} & \multicolumn{2}{c}{Predicted class} \\
\end{tabular}
\caption[Confusion matrix]{A Confusion matrix.}
\label{fig:confusion_matrix}
\end{table}
\end{frame}
\end{document}
1

A quick fix; remove the first pipe | and substitute its use in \multicolumn{1}{|C{15mm}|}{..} as below.

\documentclass[11pt]{beamer}
\usepackage{array, multirow, lmodern}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\begin{document}

\begin{frame}{Confusion matrices}
\begin{table}[htb]
\centering
\begin{tabular}{@{}cr C{15mm}|C{15mm}|@{}}
\cline{3-4}
\multirow{2}{*}{\shortstack{Actual\\class}} & $ -1 $ & \multicolumn{1}{|C{15mm}|}{$ N_\mathrm{TN} $} & $ N_\mathrm{FP} $ \\
\cline{3-4}
& $ +1 $ & \multicolumn{1}{|C{15mm}|}{$ N_\mathrm{FN} $} & $ N_\mathrm{TP} $ \\
\cline{3-4}
&   & \multicolumn{1}{c}{$ -1 $} & \multicolumn{1}{c}{$ +1 $} \\
&   & \multicolumn{2}{c}{Predicted class} 
\end{tabular}
\caption[Confusion matrix]{A Confusion matrix.}
\label{fig:confusion_matrix}
\end{table}
\end{frame}

\end{document}

enter image description here

1
  • A nice work around. Any idea what should be done if I had a huge matrix, and the cells without borders were the minority? – oliversm Aug 23 '17 at 17:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.