3

I have the following code to draw the rectangle with diagonal

\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}[yscale=0.7] \draw (0,0) rectangle (6,3) (3,3) -- (3,0) -- (0,3) (0.4,0.4) node[above right,font=\Huge]{$\mathbf 0$} foreach \X [count=\Y] in {} {(0,3.5-\Y) node[red,left] {$\X$} (-0.5+\Y,3) node[red,above] {$\X$}} foreach \X [count=\Y] in {} {(2.5+\Y,3) node[above] {$\X$}}; \end{tikzpicture}

\end{document}

Could you please help me edit above code to include the red brackets? Thank you so much for your help!

enter image description here

Akira
  • 1,215

1 Answers1

7

You can use a brace decoration for that, the ones from the calligraphy library are IMHO particularly appealing. Note that for the symmetric rectangle here you could just use a rectangle node, but this harder to generalize to asymmetric cases, so I keep the rectangle path.

\documentclass[12pt]{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing,calligraphy}
\begin{document}

\begin{tikzpicture}[yscale=0.7, brace/.style={thick,decorate, decoration={calligraphic brace, amplitude=7pt,raise=0.5ex}}] \draw (0,0) coordinate (O) rectangle (6,3) coordinate (TR) (3,3) coordinate (T) -- (3,0) coordinate (B) -- (0,3) coordinate (TL) (0.4,0.4) node[above right,font=\Huge]{$\mathbf{0}$}; \draw[brace] (O) -- node[left=1.5ex]{$I$} (TL); \draw[brace] (TL) -- node[above=1.5ex]{$I$} (T); \draw[brace] (T) -- node[above=1.5ex]{$J$} (TR); \end{tikzpicture} \end{document}

enter image description here