我在平衡具有水平分隔线的矩阵中的垂直间距时遇到了麻烦,就像下面的 MWE 一样:
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.1}
\raggedbottom
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage[table]{xcolor}
\definecolor{gray1}{RGB}{100,100,100}
\begin{document}
\setlength{\abovedisplayskip}{2ex}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayskip}{\abovedisplayskip}
\setlength{\belowdisplayshortskip}{\belowdisplayskip}
\setlength{\jot}{3ex}
\begin{equation}
M =\!
\arrayrulecolor{gray1}
\left[ \begin{array}{c|ccc}
A & 0 & 0 & E \\[2.1pt] % To be adjusted
\hline \\[-12.5pt] % To be adjusted
0 & B & 0 & 0 \\[1em]
0 & 0 & C & 0 \\[1em]
E & 0 & 0 & D
\end{array} \right]\!.
\end{equation}
Bla bla blabla:
\begin{equation}
M =\!
\arrayrulecolor{gray1}
\left[ \begin{array}{c|ccc}
A & 0 & 0 & E \\[1ex] % To be adjusted
\hline \\ % To be adjusted
0 & B & 0 & 0 \\[1em]
0 & 0 & C & 0 \\[1em]
E & 0 & 0 & D
\end{array} \right]\!.
\end{equation}
\end{document}
预览 :
\\[2.1pt]
在第一个矩阵中,我仅通过眼睛使用和调整了垂直间距\\[-12.5pt]
,这显然是一种黑客行为(但结果并不正确)。
我需要第一行和第二行中的元素具有与它们下方所有其他行相同的垂直间距 ( \\[1em]
)。我该如何实现这一点,而不是用眼睛调整垂直间距?
答案1
是不是如你所愿呢?
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage[nodisplayskipstretch]{setspace}
\setstretch{1.1}
\raggedbottom
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage[table]{xcolor}
\definecolor{gray1}{RGB}{100,100,100}
\begin{document}
\setlength{\abovedisplayskip}{2ex}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayskip}{\abovedisplayskip}
\setlength{\belowdisplayshortskip}{\belowdisplayskip}
\setlength{\jot}{3ex}
\begin{equation}
M =\!
\arrayrulecolor{gray1}
\left[ \begin{array}{c|ccc}
A & 0 & 0 & E \\[2.1pt] % To be adjusted
\hline \\[-12.5pt] % To be adjusted
0 & B & 0 & 0 \\[1em]
0 & 0 & C & 0 \\[1em]
E & 0 & 0 & D
\end{array} \right]\!.
\end{equation}
Bla bla blabla:
\begin{equation}
M =\!
\arrayrulecolor{gray1}
\left[ \begin{array}{c|ccc}
A & 0 & 0 & E \\[0.5ex] % To be adjusted
\hline \\[\dimexpr 1em-0.5ex-\arrayrulewidth-\jot] % To be adjusted
0 & B & 0 & 0 \\[1em]
0 & 0 & C & 0 \\[1em]
E & 0 & 0 & D
\end{array} \right]\!.
\end{equation}
\end{document}
编辑:要使水平线垂直居中于上、下行,请使用以下代码:
\begin{equation}
M =\!
\arrayrulecolor{gray1}
\left[ \begin{array}{c|ccc}
A & 0 & 0 & E \\[\dimexpr 0.5em-0.5\arrayrulewidth] % To be adjusted
\hline \\[\dimexpr 0.5em-0.5\arrayrulewidth-\jot] % To be adjusted
0 & B & 0 & 0 \\[1em]
0 & 0 & C & 0 \\[1em]
E & 0 & 0 & D
\end{array} \right]\!.
\end{equation}