我怎样才能使这个矩阵看起来更清晰或更漂亮?一定有一个包可以让它看起来更好。现在它看起来像一个 80 年代的旧 TeX 表。
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{table}
\centering
\begin{tabular}{|l|c|c|c|}
\hline
& Relevant & Irrelevant & Total \\ \hline
Recommended & VP& FP& VP +FP \\ \hline
Not recommended & FN & VN & FN +VN\\ \hline
Total & VP + FN & FP + VN & $N$ \\ \hline
\end{tabular}
\end{table}
\end{document}
答案1
我建议使用以下两种布局中的一种,使用一些颜色和一条粗垂直线:
\documentclass{article}
\usepackage{amsmath}
\usepackage[svgnames, table]{xcolor}
\usepackage{array, booktabs}
\begin{document}
\begin{table}
\centering
\arrayrulecolor{Gainsboro!50!Lavender}
\begin{tabular}{r!{\color{Gainsboro!50!Lavender}\vrule width 0.25em}ccc}
\multicolumn{1}{r}{}& Relevant & Irrelevant & Total \\ \cmidrule[1pt]{2-4}
Recommended & VP& FP& VP +FP \\[1ex]
Not recommended & FN & VN & FN +VN\\[1ex]
Total & VP + FN & FP + VN & $N$ \\ \cmidrule[1pt]{2-4}
\end{tabular}
\vskip 1cm
\arrayrulecolor{Gainsboro!50!Lavender}\setlength{\extrarowheight}{2pt}
\begin{tabular}{r!{\color{Gainsboro!50!Lavender}\vrule width 0.25em\enspace }ccc}
\rowcolor{Gainsboro!50!Lavender} \multicolumn{1}{r}{\cellcolor{white}}& Relevant & Irrelevant & Total \\
Recommended & VP& FP& VP +FP \\[0.5ex]
Not recommended & FN & VN & FN +VN\\[0.5ex]
Total & VP + FN & FP + VN & $N$ \\ \cmidrule[1pt]{2-4}
\end{tabular}%(l{0.2em})
\end{table}
\end{document}
答案2
很多人推荐booktabs
。简洁而优雅。
\documentclass{article}
\usepackage{amsmath}
\usepackage{booktabs}
\begin{document}
\begin{table}
\centering
\begin{tabular}{@{}lccc@{}}
\toprule
& Relevant & Irrelevant & Total \\
\midrule
Recommended & VP & FP & VP +FP \\
Not commended & FN & VN & FN +VN \\
Total & VP + FN & FP + VN & $N$ \\
\bottomrule
\end{tabular}
\end{table}
\end{document}