2

This question might be a little bit subjective, but I am looking for inspiration of how I could tweak this table (It is a confusion matrix)? (I don't like the layout) Do you have any advice?

This is how it looks:

enter image description here

    \documentclass{article}
\usepackage[utf8]{inputenc}

\begin{document}

   \begin{table}[]
    \centering
    \begin{tabular}{l|l|c|c|c}
        \multicolumn{2}{c}{}&\multicolumn{2}{c}{References}&\\
        \cline{3-4}
        \multicolumn{2}{c|}{}&witht&Non&\multicolumn{1}{c}{}\\
        \cline{2-4}
        \multirow{Predictions}& witht & 34269 & 67101 & \\
        \cline{2-4}
        & Non & 2969 & 9053 & \\
        \cline{2-4}
        \multicolumn{1}{c}{} & \multicolumn{1}{c}{Actual} & \multicolumn{1}{c}{$38074$} & \multicolumn{ 1}{c}{$76154$} & \multicolumn{1}{c}{$$}\\
        \end{tabular}           
    \end{table}

\end{document}
  • please, gives us a context of this table in form of a complete but small document, which we can compile as it is and which provide page layout of your document. – Zarko Oct 21 at 6:02
  • Please, correct you code that it will become compilable. – Zarko Oct 21 at 6:18
  • @Zarko It is a confusion matrix, I edited my post – jennifer ruurs Oct 21 at 6:18
  • 2
    no, you not add needed packages. also in code is some error. Please test your MWE yourself. – Zarko Oct 21 at 6:20
  • 2
    I already told you in one of my previous comment. just test you code (MWE) and see errors. Correct this errors (add missing packages at least). – Zarko Oct 21 at 6:39
6

Your table doesn't seem human-made, it's very likely it's the output of some tool.

However, there are some errors.

The syntax of \multirow is \multirow{number rows}{width}{text} (using * as width in the multirow command, the text argument’s natural width is used, see https://texblog.org/2012/12/21/multi-column-and-multi-row-cells-in-latex-tables/), you missed the first two arguments (hence, it is not clear if "Predictions" should be at center of 2 or 3 rows).

Moreover, you defined 5 columns but only 4 have values.

Since the standard for professional tables says to avoid vertical rules, this is my suggestion (with my supposition about the position of "Prediction"):

\documentclass{article}
\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}

\begin{document}
\begin{table}[htb]
    \centering
    \begin{tabular}{llrr}
        \toprule         
        &&\multicolumn{2}{c}{References}\\
        \cmidrule{3-4}
        &&\multicolumn{1}{c}{witht}&\multicolumn{1}{c}{Non}\\
        \midrule
        \multirow{2}{*}{Predictions}& witht & 34269 & 67101 \\
        & Non & 2969 & 9053  \\
        \midrule
        Actual & & 38074 & 76154\\
        \bottomrule
    \end{tabular}           
\end{table}
\end{document}

enter image description here

  • I indeed used a table generator for it. This looks awesome thank you! – jennifer ruurs Oct 21 at 6:28
  • @jenniferruurs You're welcome! Thank you for accepting my answer! – CarLaTeX Oct 21 at 6:38
4

another possibilities ...

\documentclass{article}
\usepackage{makecell, multirow}
\usepackage{siunitx}
\usepackage{xparse}
\NewExpandableDocumentCommand\mcc{O{1}m}
    {\multicolumn{#1}{c}{#2}}

\begin{document}
    \begin{table}[ht]
    \centering
\setcellgapes{5pt}
\makegapedcells
\sisetup{group-four-digits}
    \begin{tabular}{ll *{2}{S[table-format=5.0]}}
\mcc[2]{}       & \mcc[2]{References}   \\
        \cline{2-4}
\multirow{2.4}{*}{Predictions}
    & width     & 34269 & 67101         \\    
%        \cline{2-4}
    & Non       & 2969  & 9053          \\
        \cline{2-4}
\mcc{Actual}  
    & \mcc{}    &\mcc{\tablenum[table-format=5.0]{38074}}   
                        & \mcc{\tablenum[table-format=5.0]{76154}}  \\
        \cline{2-4}
        \end{tabular}
    \end{table}
\end{document}

enter image description here

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.