# How to draw this special matrix with two diagonal braces?

How to draw this special matrix with two diagonal braces? Can it be done without TikZ? If we use TikZ, then how to draw? Can anyone help me? Much easier, much better. Thanks in advance! • I'd simply use \begin{pmatrix} I_n & 0 \\ 0 & -I_m\end{pmatrix}, where I_n is the n ⨉ n identity matrix. – egreg Dec 11 '16 at 9:53

I can think of no way for this to be done without TikZ. However, based on what can be found here, the TikZ Matrix library provides a fairly easy-to-use solution.

One possible way is as follows:

\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} You might want to adjust the end points of the braces. To do this, you need to use the calc library (already loaded in the code above) and write something like this:

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

• Welcome to TeX.SX – Johannes_B Dec 11 '16 at 9:55
• Thanks for your help, you are very knowledgeable and enthusiastic! – mbfkk Dec 13 '16 at 3:49