\begin{center}
\begin{tabular}{c|cc|c|}
& $A$ & NOT $A$ & SUM\\ \hline
$B$ & $P(A$ AND$\,B)$ & $P($NOT $A$ AND$\,B)$ & $P(B)$\\
NOT $B$ &$P(A\,$NOT$\,B)$ &$P($NOT $A\,$AND NOT$\,B)$ & $P($NOT $B)$ \\ \hline
& $P(A)$ & $P($NOT $A)$& $1$\\ \hline
\end{tabular}
\end{center}
答案1
无需任何附加软件包(我假设 Comic Sans 不是您的梦想):
\documentclass{article}
\begin{document}
\begin{center}
\begin{tabular}{c|cc|c|}
\multicolumn{1}{c}{}& $A$ &\multicolumn{1}{c}{ NOT $A$} &\multicolumn{1}{c}{ SUM}\\
%\hline
\cline{2-4}
$B$ & $P(A$ AND$\,B)$ & $P($NOT $A$ AND$\,B)$ & $P(B)$\\
NOT $B$ &$P(A\,$NOT$\,B)$ &$P($NOT $A\,$AND NOT$\,B)$ & $P($NOT $B)$ \\
%\hline
\cline{2-4}
& $P(A)$ & $P($NOT $A)$& $1$\\
%\hline
\cline{2-4}
\end{tabular}
\end{center}
\end{document}
答案2
这很容易blkarray
:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{mathtools, blkarray}
\begin{document}
\[ \everymath{\displaystyle}\setlength{\BAextrarowheight}{2pt}
\begin{blockarray}{cccc}
& A & \text{NOT }A & \text{SUM} \\
\BAhhline{~---}
\begin{block}{c|cc|c|}
B & P(A\text{ AND}B) & P(\text{NOT }A\text{ AND }B) & P(B)\\
\text{NOT }B &P(A\text{ NOT }B) &P(\text{NOT }A\text{ AND NOT }B) & P(\text{NOT }B) \\
\BAhhline{~|---|}
& P(A) & P(\text{NOT }A)& 1\\
\BAhhline{~---}
\end{block}
\end{blockarray} \]
\end{document}
答案3
使用\multicolumn
命令来抑制特定单元格的垂直标尺。如果表格宽度不符合您的要求,请尝试修改提供的宽度{\textwidth}
\documentclass{article}
\usepackage{amsmath}
\renewcommand{\arraystretch}{1.7}
\usepackage{ragged2e}
\usepackage{tabularx}
\newcolumntype{C}{ >{ \arraybackslash \Centering } X }
\usepackage{booktabs}
\usepackage{makecell}
\begin{document}
\noindent
\begin{table*}
\centering
\begin{tabularx}{\textwidth}{>{\hsize=0.3\hsize}C |>{\hsize=1.5\hsize} C>{\hsize=1.5\hsize}C| >{\hsize=0.7\hsize}C|}
\multicolumn{1}{c}{} & \multicolumn{1}{c}{$A$} & \multicolumn{1}{c}{$A^{'}$} & \multicolumn{1}{c}{SUM}
\\
\Xcline{2-4}{0.2mm}
$B$ & $P(A \text{ AND } B)$ & $P(\text{NOT } A \text{ AND } B)$ & $P(B)$
\\
$B^{'}$ & $P(A \text{ AND NOT } B)$ & $P(\text{NOT } A \text{ AND NOT} B)$ & $P($NOT $B)$
\\
\Xcline{2-4}{0.2mm}
& $P(A)$ & $P($NOT $A)$& $1$
\\
\Xcline{2-4}{0.2mm}
\end{tabularx}
\end{table*}
\end{document}