我在矩阵内绘制水平线时遇到了麻烦。从这个 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{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tensor}
\begin{document}
%\setlength{\abovedisplayskip}{1em}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayskip}{\abovedisplayskip}
\setlength{\belowdisplayshortskip}{\belowdisplayskip}
\setlength{\jot}{3ex}
\begin{equation}
R = \left[ \begin{array}{ccc|ccc}
\tensor{R}{_{0101}} & \tensor{R}{_{0102}} & \tensor{R}{_{0103}} & \tensor{R}{_{0123}} & \tensor{R}{_{0131}} & \tensor{R}{_{0112}} \\[2ex]
\tensor{R}{_{0102}} & \tensor{R}{_{0202}} & \tensor{R}{_{0203}} & \tensor{R}{_{0223}} & \tensor{R}{_{0231}} & \tensor{R}{_{0212}} \\[2ex]
\tensor{R}{_{0103}} & \tensor{R}{_{0203}} & \tensor{R}{_{0303}} & \tensor{R}{_{0323}} & \tensor{R}{_{0331}} & \tensor{R}{_{0312}}
\\[\dimexpr 1ex+2\arrayrulewidth] \hline \\[\dimexpr 1ex-2\arrayrulewidth-\jot]
\tensor{R}{_{0123}} & \tensor{R}{_{0223}} & \tensor{R}{_{0323}} & \tensor{R}{_{2323}} & \tensor{R}{_{2331}} & \tensor{R}{_{2312}} \\[2ex]
\tensor{R}{_{0131}} & \tensor{R}{_{0231}} & \tensor{R}{_{0331}} & \tensor{R}{_{2331}} & \tensor{R}{_{3131}} & \tensor{R}{_{3112}} \\[2ex]
\tensor{R}{_{0112}} & \tensor{R}{_{0212}} & \tensor{R}{_{0312}} & \tensor{R}{_{2312}} & \tensor{R}{_{3112}} & \tensor{R}{_{1212}}
\end{array} \right]\!.
\end{equation}
\end{document}
预览:
那么我该如何修改该代码,使得水平线在矩阵中垂直平衡,而下面没有白孔?
答案1
来自--https://tex.stackexchange.com/questions/240859/dividing-line-in-a-matrix
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{booktabs}
\usepackage{tensor}
\begin{document}
\[
M =
\left( \begin{array}{c|c}
A & B \\
\midrule
C & D \\
\end{array}\right)
\]
\[
R = \left[ \begin{array}{ccc|ccc}
\tensor{R}{_{0101}} & \tensor{R}{_{0102}} & \tensor{R}{_{0103}} & \tensor{R}{_{0123}} & \tensor{R}{_{0131}} & \tensor{R}{_{0112}} \\[2ex]
\tensor{R}{_{0102}} & \tensor{R}{_{0202}} & \tensor{R}{_{0203}} & \tensor{R}{_{0223}} & \tensor{R}{_{0231}} & \tensor{R}{_{0212}} \\[2ex]
\tensor{R}{_{0103}} & \tensor{R}{_{0203}} & \tensor{R}{_{0303}} & \tensor{R}{_{0323}} & \tensor{R}{_{0331}} & \tensor{R}{_{0312}}
\\ \midrule
\tensor{R}{_{0123}} & \tensor{R}{_{0223}} & \tensor{R}{_{0323}} & \tensor{R}{_{2323}} & \tensor{R}{_{2331}} & \tensor{R}{_{2312}} \\[2ex]
\tensor{R}{_{0131}} & \tensor{R}{_{0231}} & \tensor{R}{_{0331}} & \tensor{R}{_{2331}} & \tensor{R}{_{3131}} & \tensor{R}{_{3112}} \\[2ex]
\tensor{R}{_{0112}} & \tensor{R}{_{0212}} & \tensor{R}{_{0312}} & \tensor{R}{_{2312}} & \tensor{R}{_{3112}} & \tensor{R}{_{1212}}
\end{array} \right]\!.
\]
\end{document}
编辑 - 与交叉点没有孔对齐=符号
R = \left[ \begin{array}{@{\,}ccc|ccc@{\,}}
\tensor{R}{_{0101}} & \tensor{R}{_{0102}} & \tensor{R}{_{0103}} & \tensor{R}{_{0123}} & \tensor{R}{_{0131}} & \tensor{R}{_{0112}} \\
\tensor{R}{_{0102}} & \tensor{R}{_{0202}} & \tensor{R}{_{0203}} & \tensor{R}{_{0223}} & \tensor{R}{_{0231}} & \tensor{R}{_{0212}} \\
\tensor{R}{_{0103}} & \tensor{R}{_{0203}} & \tensor{R}{_{0303}} & \tensor{R}{_{0323}} & \tensor{R}{_{0331}} & \tensor{R}{_{0312}}
\\ \hline
\tensor{R}{_{0123}} & \tensor{R}{_{0223}} & \tensor{R}{_{0323}} & \tensor{R}{_{2323}} & \tensor{R}{_{2331}} & \tensor{R}{_{2312}} \\
\tensor{R}{_{0131}} & \tensor{R}{_{0231}} & \tensor{R}{_{0331}} & \tensor{R}{_{2331}} & \tensor{R}{_{3131}} & \tensor{R}{_{3112}} \\
\tensor{R}{_{0112}} & \tensor{R}{_{0212}} & \tensor{R}{_{0312}} & \tensor{R}{_{2312}} & \tensor{R}{_{3112}} & \tensor{R}{_{1212}}
\end{array} \right]\!.
答案2
使用最新版本(2020-07-31 的 v 5.1),序言中nicematrix
指定的垂直规则(类似于)从未被破坏(因为它们实际上是由 PGF/Tikz 绘制的)。|
{NiceArray}
{array}
array
因此,您可以直接书写而不会破坏垂直规则:
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tensor}
\usepackage{nicematrix}
\begin{document}
\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayskip}{\abovedisplayskip}
\setlength{\belowdisplayshortskip}{\belowdisplayskip}
\setlength{\jot}{3ex}
\begin{equation}
R = \left[ \begin{NiceArray}{ccc|ccc}
\tensor{R}{_{0101}} & \tensor{R}{_{0102}} & \tensor{R}{_{0103}} & \tensor{R}{_{0123}} & \tensor{R}{_{0131}} & \tensor{R}{_{0112}} \\[2ex]
\tensor{R}{_{0102}} & \tensor{R}{_{0202}} & \tensor{R}{_{0203}} & \tensor{R}{_{0223}} & \tensor{R}{_{0231}} & \tensor{R}{_{0212}} \\[2ex]
\tensor{R}{_{0103}} & \tensor{R}{_{0203}} & \tensor{R}{_{0303}} & \tensor{R}{_{0323}} & \tensor{R}{_{0331}} & \tensor{R}{_{0312}}
\\[\dimexpr 1ex+2\arrayrulewidth] \hline \\[\dimexpr 1ex-2\arrayrulewidth-\jot]
\tensor{R}{_{0123}} & \tensor{R}{_{0223}} & \tensor{R}{_{0323}} & \tensor{R}{_{2323}} & \tensor{R}{_{2331}} & \tensor{R}{_{2312}} \\[2ex]
\tensor{R}{_{0131}} & \tensor{R}{_{0231}} & \tensor{R}{_{0331}} & \tensor{R}{_{2331}} & \tensor{R}{_{3131}} & \tensor{R}{_{3112}} \\[2ex]
\tensor{R}{_{0112}} & \tensor{R}{_{0212}} & \tensor{R}{_{0312}} & \tensor{R}{_{2312}} & \tensor{R}{_{3112}} & \tensor{R}{_{1212}}
\end{NiceArray} \right]\!.
\end{equation}
\end{document}