0

I'm trying to create a nice confusion matrix with a bookstab table. I'm almost satisfied except for the too large gap between the last two columns. I've tried several things like setting the column width in the beginning or directly in the multicolumn statement. Unfortunately, I always got an error message or it didn't remove the gap. Any ideas?

This is my code:

\begin{table}[ht]

\centering \caption{Konfusionsmatrix}

\begin{tabular}{@{}llrc@{}}

\toprule
                  &  & \multicolumn{2}{l}{\textbf{Vorhergesagte Klasse}}\\ \midrule
                  &  &     0    & 1  \\

\multirow{2}{*}{\textbf{Wahre Klasse} } & 0     & 333&       57 \\
                                            & 1     & 48 &       40\\ \bottomrule

\end{tabular}

\label{cm_modell2}

\end{table}

And it looks like this: Confusion matrix

1 Answer 1

1

Here is away, more or less by trial and error:

\documentclass[german]{report}
\usepackage{babel} 
\usepackage{booktabs, multirow}
\usepackage{array, makecell, caption}
\renewcommand{\theadfont}{\normalsize\bfseries}

\begin{document}

\begin{table}[ht]
\sffamily\captionsetup{font=sf}
\centering \caption{Konfusionsmatrix}

\begin{tabular}{@{}llwr{2.2em}wc{2em}}
\toprule
                  & & \multicolumn{2}{l}{\thead{\makebox[0pt]{Vorhergesagte}\\ Klasse}}\\ \midrule
                  & & 0 & 1 \\
\multirow{2}{*}{\textbf{Wahre Klasse} } & 0 & 333& 57 \\
                                            & 1 & 48 & 40\\ \bottomrule
\end{tabular}
\label{cm_modell2}

\end{table}

\end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .