等式两边的矩阵行对齐,带规则

等式两边的矩阵行对齐,带规则

我有以下代码来生成矩阵方程,在 LHS 矩阵上,添加了一些规则,导致 RHS 对应的行未对齐(垂直)。如果我坚持使用当前代码,如何调整 RHS 矩阵中的细微 vspace?还有没有办法调整规则的灰度(使它们不那么分散注意力)?

\documentclass{article}
\usepackage{mathtools}
% add vertical lines
\makeatletter
\renewcommand*\env@matrix[1][*\c@MaxMatrixCols c]{%
  \hskip -\arraycolsep
  \let\@ifnextchar\new@ifnextchar
  \array{#1}}
\makeatother
\usepackage{booktabs} % add horizontal lines
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,matrix,positioning}
\newcommand{\tikzmark}[2]{\tikz[overlay, remember picture] \node[inner sep=0pt, outer sep=3pt, anchor=base] (#1) {#2};}

\begin{document}
\begin{equation}
  \begin{bmatrix}[cc|c|c|c|c]
\phantom{abcd}      & \phantom{ }       &       &       & 0     & \phantom{abcd}  \\
      &       &       &       & 0     &  \\
      &       &       &       & \cdots     &  \\
      &       &       &       & \cdots     &  \\ \cmidrule(lr){1-6}
      &       & a^{*}_{ts}     &       & 1     &  \\  \cmidrule(lr){1-6}
      &       &       &       & 0     &  \\
      &       &       &       & \cdots     &  \\
      &       &       &       & \cdots     &  \\
      &       &       &       & \cdots     &  \\
      &       &       &       & 0     &  \\
      &       &       &       & 0     &  \\  \cmidrule(lr){1-6}
      &       & \tikzmark{enter}{$c^{*}_s$}     &       & \tikzmark{leaving}{$c^{*}_t$}     &  \\
    \end{bmatrix}
    =
    \begin{bmatrix}
      \phantom{four} \\
 \\
 \\
 \\
b^{*}_t \\
 \\
 \\
 \\
 \\
 \\
 \\
 \\
-v \\
    \end{bmatrix}
\end{equation}
\tikz[overlay,remember picture] {
  \draw[<-,>=stealth] (enter) -- ++(0,-1cm) node [label={[xshift=-8pt,yshift=-20pt]entering}] {};
  \draw[<-,>=stealth] (leaving) -- ++(0,-1cm) node[label={[xshift=8pt,yshift=-20pt]leaving}] {};
}
\end{document}

在此处输入图片描述

答案1

在这种情况下,array更加灵活:

\documentclass{article}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,matrix,positioning}
\newcommand{\tikzmark}[2]{\tikz[overlay, remember picture] \node[inner sep=0pt, outer sep=3pt, anchor=base] (#1) {#2};}

\begin{document}
\begin{equation}
\left[
\begin{array}{@{\qquad}|c|@{\quad}|c|@{\qquad}}
           & 0      \\
           & 0      \\
           & \cdots \\
           & \cdots \\ \hline
a^{*}_{ts} & 1      \\ \hline
           & 0      \\
           & \cdots \\
           & \cdots \\
           & \cdots \\
           & 0      \\
           & 0      \\ \hline
\tikzmark{enter}{$c^{*}_s$} & \tikzmark{leaving}{$c^{*}_t$}
\end{array}
\right]
=
\left[\begin{array}{@{}c@{}}
\\ \\ \\ \\
b^{*}_t \\
\\ \\ \\ \\ \\ \\
-v
\end{array}\right]
\end{equation}
\tikz[overlay,remember picture] {
  \draw[<-,>=stealth] (enter) -- ++(0,-1cm) node [label={[xshift=-8pt,yshift=-20pt]entering}] {};
  \draw[<-,>=stealth] (leaving) -- ++(0,-1cm) node[label={[xshift=8pt,yshift=-20pt]leaving}] {};
}
\end{document}

在此处输入图片描述

如果您还加载xcolorcolortbl,则可以更改规则的色调:

\documentclass{article}
\usepackage{mathtools,xcolor,colortbl}
\usepackage{tikz}
\usetikzlibrary{arrows,shapes,matrix,positioning}
\newcommand{\tikzmark}[2]{\tikz[overlay, remember picture] \node[inner sep=0pt, outer sep=3pt, anchor=base] (#1) {#2};}

\begin{document}
\begin{equation}
\arrayrulecolor{black!30}
\left[
\begin{array}{@{\qquad}|c|@{\quad}|c|@{\qquad}}
           & 0      \\
           & 0      \\
           & \cdots \\
           & \cdots \\ \hline
a^{*}_{ts} & 1      \\ \hline
           & 0      \\
           & \cdots \\
           & \cdots \\
           & \cdots \\
           & 0      \\
           & 0      \\ \hline
\tikzmark{enter}{$c^{*}_s$} & \tikzmark{leaving}{$c^{*}_t$}
\end{array}
\right]
=
\left[\begin{array}{@{}c@{}}
\\ \\ \\ \\
b^{*}_t \\
\\ \\ \\ \\ \\ \\
-v
\end{array}\right]
\arrayrulecolor{black}
\end{equation}
\tikz[overlay,remember picture] {
  \draw[<-,>=stealth] (enter) -- ++(0,-1cm) node [label={[xshift=-8pt,yshift=-20pt]entering}] {};
  \draw[<-,>=stealth] (leaving) -- ++(0,-1cm) node[label={[xshift=8pt,yshift=-20pt]leaving}] {};
}
\end{document}

在此处输入图片描述

最后必须重新建立颜色,因为\arrayrulecolor这是一个全局声明。

相关内容