如何绘制这个带有两个对角括号的特殊矩阵?

如何绘制这个带有两个对角括号的特殊矩阵?

如何绘制这个带有两个对角括号的特殊矩阵?没有 TikZ 可以做到吗?如果我们使用 TikZ,那么如何绘制?有人能帮助我吗?更容易,更好。提前谢谢! 矩阵

答案1

我想不出没有 TikZ 就无法做到这一点。然而,根据可以找到的信息这里,TikZ Matrix 库提供了一个相当易于使用的解决方案。

一种可能的方法如下:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{matrix,decorations.pathreplacing,calc}

\begin{document}
\[
   \begin{tikzpicture}[decoration={brace,amplitude=5pt},baseline=(current bounding box.west)]
     \matrix (magic) [matrix of math nodes,left delimiter=(,right delimiter=)] {
      1 \\
      & 1 \\
      & & \ddots \\
      & & & 1 \\
      & & & & -1 \\
      & & & & & -1 \\
      & & & & & & \ddots \\
      & & & & & & & -1\\
     };
     \draw[decorate] (magic-1-1.north) -- (magic-4-4.north east) node[above=5pt,midway,sloped] {$n$ copies of $1$};
     \draw[decorate] (magic-5-5.north east) -- (magic-8-8.north east) node[above=5pt,midway,sloped] {$m$ copies of $-1$};
   \end{tikzpicture}
\]
\end{document}

在此处输入图片描述

您可能需要调整括号的端点。为此,您需要使用 calc 库(已在上面的代码中加载)并编写如下内容:

\draw[decorate] ($(magic-1-1.north)+(.2,.1)$) -- ($(magic-4-4.north east)+(.15,.1)$) node[above=5pt,midway,sloped] {$n$ copies of $1$};

相关内容