我正在使用此代码并拼命尝试在外部左侧添加文字“实际”并在底部中心添加文字“预测”。
\begin{table}[h]
\centering
\begin{tabular}{|p{.4\textwidth}|p{.4\textwidth}|}
\hline&\\
True Positives (TPs): 70
\begin{itemize}
\item real outcome: Positive
\item predicted outcome: Positive
\end{itemize}
& False Positives (FPs): 5
\begin{itemize}
\item real outcome: Negative
\item predicted outcome: Positive
\end{itemize} \\
\hline&\\
False Negatives (FNs): 8
\begin{itemize}
\item real outcome: Negative
\item predicted outcome: Positive
\end{itemize}
& True Negatives (TNs): 17
\begin{itemize}
\item real outcome: Negative
\item predicted outcome: Negative
\end{itemize} \\
\hline
\end{tabular}
\caption{Example of a confusion matrix}
\label{tab:cm}
\end{table}
我可以将其用于\multicolumn
底部,但它直接卡在水平线下方,看起来不太好。
答案1
\savebox
这里有一个使用 a和 a 的方法,\rotatebox
只是为了跟随您而不使用多列:
\documentclass{article}
\usepackage[margin=3.5cm]{geometry}
\usepackage{graphicx}
\author{John Doe}
\title{Lorem Ipsum}
\newsavebox{\mybox}
\begin{document}
\begin{table}[h]
\centering
\savebox\mybox{\hbox{\begin{tabular}{|p{.4\textwidth}|p{.4\textwidth}|}
\hline\\
True Positives (TPs): 70
\begin{itemize}
\item real outcome: Positive
\item predicted outcome: Positive
\end{itemize}
& False Positives (FPs): 5
\begin{itemize}
\item real outcome: Negative
\item predicted outcome: Positive
\end{itemize} \\
\hline\\
False Negatives (FNs): 8
\begin{itemize}
\item real outcome: Negative
\item predicted outcome: Positive
\end{itemize}
& True Negatives (TNs): 17
\begin{itemize}
\item real outcome: Negative
\item predicted outcome: Negative
\end{itemize} \\
\hline
\end{tabular}}}
\rotatebox{90}{actual}\hspace{10pt}\parbox{\wd\mybox}{\usebox{\mybox}}\\[10pt]
\hspace{20pt}{\parbox{\wd\mybox}{\centering predicted}}
\caption{Example of a confusion matrix}
\label{tab:cm}
\end{table}
\end{document}
输出是你的照片之一(几乎)
答案2
对 koleygr 的解决方案进行稍微的简化。
\documentclass{article}
\usepackage[margin=3.5cm]{geometry}
\usepackage{graphicx}
\begin{document}
\begin{table}[h]
\centering
\rotatebox[origin=c]{90}{actual}\hspace{\baselineskip}%
\begin{tabular}[c]{|p{.4\textwidth}|p{.4\textwidth}|}
\hline
True Positives (TPs): 70
\begin{itemize}
\item real outcome: Positive
\item predicted outcome: Positive
\end{itemize}
& False Positives (FPs): 5
\begin{itemize}
\item real outcome: Negative
\item predicted outcome: Positive
\end{itemize} \\
\hline
False Negatives (FNs): 8
\begin{itemize}
\item real outcome: Negative
\item predicted outcome: Positive
\end{itemize}
& True Negatives (TNs): 17
\begin{itemize}
\item real outcome: Negative
\item predicted outcome: Negative
\end{itemize} \\
\hline
\end{tabular}\\[10pt]
\hspace{2\baselineskip}predicted
\caption{Example of a confusion matrix}
\label{tab:cm}
\end{table}
\end{document}