3

I made the following table:

\documentclass{article}
\usepackage{multirow}
\usepackage{multicol}

\begin{document}

\def\arraystretch{1.5}
    \begin{tabular}{|c|c|ccc|} \hline
         &  & \multicolumn{3}{c|}{Actual} \\ \hline
         & Class & Low & Med. & High \\ \hline
         \multirow{3}{*}{Prediction} & Low & $0$ & $0$ & $0$ \\
         & Med. & $10$ & $98$ & $1$ \\
         & High & $0$ & $0$ & $0$ \\ \hline
    \end{tabular}

\end{document}

Here is the result:

enter image description here

I am just curious if there is any way to get rid of the lines around the boxes that have nothing in them?

3

There is no need of multicol here.

\documentclass{article}
\usepackage{multirow}
\begin{document}
\def\arraystretch{1.5}
\begin{tabular}{|c|c|ccc|} 
    \cline{3-5}
    \multicolumn{1}{c}{} & & \multicolumn{3}{c|}{Actual} \\ \cline{2-5}
    \multicolumn{1}{c|}{} & Class & Low & Med. & High \\ \hline
     \multirow{3}{*}{Prediction} & Low & $0$ & $0$ & $0$ \\
     & Med. & $10$ & $98$ & $1$ \\
     & High & $0$ & $0$ & $0$ \\ \hline
\end{tabular}
\end{document}

enter image description here

2

I would suggest to omit all lines, looks better for me. In the following mwe I show both versions. Please see my pretty printing to be able to see the structure of the table faster ...

MWE [important code changings marked with <======]:

\documentclass{article}
\usepackage{multirow}
\usepackage{multicol}

\begin{document}

\def\arraystretch{1.5}
How about without lines:

\begin{tabular}{c c ccc} %\hline    
                              &       & \multicolumn{3}{c}{Actual} \\ %\hline
                              & Class & Low  & Med. & High \\ %\hline
  \multirow{3}{*}{Prediction} & Low   & $0$  & $0$  & $0$ \\
                              & Med.  & $10$ & $98$ & $1$ \\
                              & High  & $0$  & $0$  & $0$ \\ %\hline
\end{tabular}

Version with lines:

\begin{tabular}{|c|c|ccc|} \cline{3-5} % <==============================
  \multicolumn{2}{c}{}                & \multicolumn{3}{|c|}{Actual} \\ \cline{2-5} % <===========
  \multicolumn{1}{c|}{}       & Class & Low  & Med. & High \\ \hline % <========
  \multirow{3}{*}{Prediction} & Low   & $0$  & $0$  & $0$  \\ % <=======
                              & Med.  & $10$ & $98$ & $1$  \\
                              & High  & $0$  & $0$  & $0$  \\ \hline
\end{tabular}
\end{document}

and its result:

result

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.