我本想\offinterlineskip
删除行之间的垂直间距,但似乎行不通。我只想要最后一行之前的一个小间距。
有人知道这里出了什么问题吗?
这是混淆矩阵的代码:
{
\offinterlineskip
\centering
\hspace*{0.9cm}\MyHBoxy{A}\MyHBoxy{B}\MyHBoxy{C}\MyHBoxy{D}\MyHBoxy{PA}\par
\MyTBoxy{A}{$N_{AA}$,$N_{AB}$,$N_{AC}$,$N_{AD}$}{$\dfrac{N_{AA}}{\sum_{Ap}}$}
\MyTBoxy{B}{$N_{BA}$,$N_{BB}$,$N_{BC}$,$N_{BD}$}{$\dfrac{N_{AA}}{\sum_{Bp}}$}
\MyTBoxy{C}{$N_{CA}$,$N_{CB}$,$N_{CC}$,$N_{CD}$}{$\dfrac{N_{AA}}{\sum_{Cp}}$}
\MyTBoxy{D}{$N_{DA}$,$N_{DB}$,$N_{DC}$,$N_{DD}$}{$\dfrac{N_{AA}}{\sum_{Dp}}$}
\vspace*{2.5px}
\MyTBoxy{UA}{$\dfrac{N_{AA}}{\sum_{An}}$,$\dfrac{N_{BB}}{\sum_{Bn}}$,$\dfrac{N_{CC}}{\sum_{Cn}}$,$\dfrac{N_{DD}}{\sum_{Dn}}$}{-}
}
盒子:
\newcommand\MyVBox[1]{%
\parbox[c][.8cm][c]{1cm}{\centering\bfseries #1}%
}
\newcommand\MyHBoxy[2][\dimexpr1.25cm+2\fboxsep\relax]{%
\parbox[c][1.35cm][c]{#1}{\centering\bfseries #2}%
}
\newcommand\boxy[1]{%
\fbox{\parbox[c][1.25cm][c]{1.25cm}{\centering #1}}%
}
\newcommand\MyTBoxy[3]{%
\MyVBox{#1}
\renewcommand*\do[1]{\boxy{##1}\hspace*{-\fboxrule}}
\docsvlist{#2}
\boxy{#3}\par\vspace{-\fboxrule}
}
答案1
像这样?
像简单表格一样使用hhline
表格中的水平和垂直规则,并使用 makecell 在最后一列的单元格中获得更多垂直空间:
\documentclass[varwidth, margin=3mm]{standalone}
%\documentclass{article}
\usepackage{hhline, makecell}
\newcommand\mcbf[1]{\multicolumn{1}{c}{\mathbf{#1}}}
\begin{document}
\[
\setcellgapes{3pt}
\makegapedcells
\begin{array}{r|*{4}{c|} |c|}
\mcbf{} & \mcbf{A} & \mcbf{B} & \mcbf{C} & \mcbf{D} & \mcbf{PA} \\
\hhline{~|----||-|}
\mathbf{A} & N_{AA} & N_{AB} & N_{AC} & N_{AD} & \dfrac{N_{AA}}{\sum_{Ap}}\\
\hhline{~|----||-|}
\mathbf{B} & N_{BA} & N_{BB} & N_{BC} & N_{BD} & \dfrac{N_{AA}}{\sum_{Bp}}\\
\hhline{~|----||-|}
\mathbf{C} & N_{CA} & N_{CB} & N_{CC} & N_{CD} & \dfrac{N_{AA}}{\sum_{Cp}}\\
\hhline{~|----||-|}
\mathbf{D} & N_{DA} & N_{DB} & N_{DC} & N_{DD} & \dfrac{N_{AA}}{\sum_{Dp}}\\
\hhline{~:====::=:}
\mathbf{UA} & \dfrac{N_{AA}}{\sum_{An}}
& \dfrac{N_{BB}}{\sum_{Bn}}
& \dfrac{N_{CC}}{\sum_{Cn}}
& \dfrac{N_{DD}}{\sum_{Dn}}
& - \\
\hhline{~|----||-|}
\end{array}
\]
\end{document}