4

I want to make a table like the one in the picture. The written code draws the structure of the table but is not the correct delimitation between the rows. I also want to make the table a bigger. How can I do this? My code:

\begin{tabular}{cc|c|c|c|c|l}
\cline{3-6}
& & \multicolumn{2}{ c| }{Valori Estimate} \\ \cline{3-6}
& & Clasa & Clasa \\ \cline{1-6}
\multicolumn{1}{ |c  }{\multirow{2}{*}{Valori reale} } &
\multicolumn{1}{ |c| }{Clasa} & 3 & 2 \\ \cline{2-6}
\multicolumn{1}{ |c  }{}                        &
\multicolumn{1}{ |c| }{Clasa} & 2 & 3   \\ \cline{1-6}
\end{tabular}

This is how the table should look:

enter image description here

2 Answers 2

5
\documentclass{article}

\usepackage{multirow}

\begin{document}

\begin{table}[]
\begin{tabular}{cc|c|c|}
\cline{3-4}
  &  & \multicolumn{2}{c|}{Valori Estimate} \\
\cline{3-4} 
  &  & Clasa & Clasa \\
\hline
\multicolumn{1}{|c|}{\multirow{2}{*}{Valori reale}} & Clasa & 3 & 2 \\
\cline{2-4} 
\multicolumn{1}{|c|}{}  & Clasa & 2 & 3 \\
\hline
\end{tabular}
\end{table}

\end{document}

multirow table

4

With {NiceTabular} of nicematrix.

\documentclass{article}
\usepackage{nicematrix}

\begin{document}

\begin{table}[]
\begin{NiceTabular}{ccwc{10mm}wc{10mm}}[hvlines,corners=NW]
                          &       & \Block{1-2}{Valori Estimate} \\
                          &       & Clasa & Clasa \\
\Block{2-1}{Valori reale} & Clasa & 3     & 2 \\
                          & Clasa & 2     & 3 \\
\end{NiceTabular}
\end{table}

\end{document}

You need several compilations (because nicematrix uses PGF/Tikz nodes).

Output of the above code

4
  • Hello, François. I didn't know this package, it seems nice ;) But I have errors when compiling: ! Undefined control sequence. l.5071 \seq_set_map_x:NNn \c__nicematrix_types_of_matrix_seq \c__nicematrix_... even with mutiple compilations. Any idea?
    – SebGlav
    Jan 27, 2021 at 17:55
  • @SebGlav: I think that your LaTeX installation is not up-to-date. Jan 27, 2021 at 18:29
  • You might be right, since it doesn't compile even with nothing but the package declaration. Anyway, congrats for this nice feature of yours.
    – SebGlav
    Jan 27, 2021 at 19:20
  • I thinked that in this question there was @Zarko to create the table, but I have done a mistake. ahahha. :-)
    – Sebastiano
    Jan 27, 2021 at 21:33

You must log in to answer this question.

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