绘图块矩阵,矩阵内部带有括号

绘图块矩阵,矩阵内部带有括号

我该如何绘制这个块矩阵?我尝试使用此代码绘制它,但括号仍然保留。

`

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{nicematrix}
\usepackage{amscd}
\usepackage{tikz}
\newcommand{\mc}{\multicolumn{1}{c}}
\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt  
\begin{document}
    \begin{equation}\label{key}
    \renewcommand{\arraystretch}{1.2}
    \left[ \;
    \begin{array}{ |c c | cc | cc |cc|}
    \cline{1-2}
    &&&\mc{} && \mc{} &&\mc{} \\
    \multicolumn{1}{|c}{} & &  & \mc{} &  & \mc{} &  & \mc{} \\
    \multicolumn{2}{|c|}{\raisebox{.6\normalbaselineskip}[0pt][0pt]{$\begin{array}{ccc}
            \ast & \dots & \ast\\
            \vdots \\
            \ast& \dots & \ast
            \end{array} $}} &  & \mc{} &  & \mc{} &&\mc{} \\
        &&&\mc{} &&\mc{} && \mc{}\\
    \cline{1-4}
     \mc{} &  & & &  & \mc{} && \mc{}\\
     \mc{} &  & \multicolumn{2}{c|}{\raisebox{.6\normalbaselineskip}[0pt][0pt]{$\quad\ast \;\; $}} &  & \mc{} && \mc{} \\
    \cline{3-4}
    \mc{} &\mc{}&  &\mc{} &\cdot \\
    \mc{} &\mc{} && \mc{} & &  \mc{\cdot} \\
    \cline{7-8}
     \mc{} & \mc{} &  & \mc{}&  & & & \multicolumn{1}{ c|}{} \\
     \mc{} & \mc{} &  & \mc{} & && \multicolumn{2}{c|}{\raisebox{.6\normalbaselineskip}[0pt][0pt]{$\quad\ast \;\;$}}  \\
    \cline{7-8}
    \end{array}\;
    \right] 
    \end{equation}  
\end{document}`

在此处输入图片描述

答案1

拥有强大的包裹nicematrix在此处输入图片描述

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
\usetikzlibrary {decorations.pathreplacing}
\setcounter{MaxMatrixCols}{20}
\def\myzeroa{\Block{2-2}<\large>{O}}

\begin{document}
\[
\begin{bNiceMatrix}[columns-width=3mm, nullify-dots,
  code-after=\line{7-7}{9-9},
  extra-left-margin=3mm,
  extra-right-margin=3mm,
  xdots/shorten=1em, first-row,
  last-row,
  ]
  \\
  \lambda_1 && \myzeroa\\
  & \lambda_1 && \\
  \myzeroa && \Ddots \\
  &&& \lambda_1 \\
  &&&& \lambda_2 \\
  &&&&& \Ddots & \\
  &&&&&& \lambda_2 \\
  \\
  &&&&&&&& \lambda_3 \\
  &&&&&&&&& \Ddots \\
  &&&&&&&&&& \lambda_3 \\
\\
\CodeAfter
\begin{tikzpicture}[decoration={brace, amplitude=2mm}]
  \draw[teal] (1-|1) -- (5-|1) -- (5 -| 5) -- (1 -| 5) -- cycle;
  \draw[cyan] (5 -| 5) -- (8 -| 5) -- (8 -| 8) -- (5 -| 8) -- cycle;
  \draw[red!70] (9 -| 9) -- (12 -| 9) -- (12 -| 12) -- (9 -| 12) -- cycle;

  \node at (6 -| 7) {\large$O$};
  \node at (7 -| 6) {\large$O$};
  \node at (10 -| 11) {\large$O$};
  \node at (11 -| 10) {\large$O$};
  \node[transform shape, scale=3] at (3 -| 10) {$O$};
  \node[transform shape, scale=3] at (9 -| 3) {$O$};

  \begin{scope}[node font=\scriptsize]
  \draw[decorate, teal] ([yshift=1mm]1) -- ([yshift=1mm]1 -| 5)
    node[midway, above=1.5mm] {$d_1 = g_1$};
  \draw[decorate, teal] ([shift={(1mm, -2pt)}]1 -| 5) -- ([shift={(1mm, 2pt)}]5 -| 5)
    node[midway, right=1.5mm] {$d_1 = g_1$};

  \draw[decorate, cyan] ([yshift=-1mm]8 -| 8) -- ([yshift=-1mm]8 -| 5)
    node[midway, below=1.5mm] {$d_2 = g_2$};
  \draw[decorate, cyan] ([xshift=1mm]5 -| 8) -- ([xshift=1mm]8 -| 8)
    node[midway, right=1.5mm] {$d_2 = g_2$};

  \draw[decorate, red!60] ([yshift=1mm]9 -| 9) -- ([yshift=1mm]9 -| 12)
    node[midway, above=1.5mm] {$d_3 = g_3$};
  \draw[decorate, red!60] ([xshift=-1mm]12 -| 9) -- ([xshift=-1mm]9 -| 9)
    node[midway, left=1.5mm] {$d_3 = g_3$};
  \end{scope}
\end{tikzpicture}
\end{bNiceMatrix}
\]
\end{document}

相关内容