3

I was going to sketch a number of rectangles around the elements of a matrix, something like the picture but I didn't know how to do this. I would be grateful if someone could help me. Here is my matrix code without rectangles:

\begin{equation}
\begin{bmatrix}
\mathbf {c_0}& & & \\
&\mathbf {c_1 }& & \\
& &\ \ddots & \\
&& &\mathbf {c_{r-1}} \\
\end{bmatrix}_{(n+1)(r+1)\times4r}
\end{equation}

enter image description here

2
  • Please make your code compilable. You can format it by selecting it and hitting ctrl+k or the {} button in the editor. (This will indent it by 4 spaces, which does the trick.)
    – cfr
    Commented May 21, 2017 at 18:27
  • See tex.stackexchange.com/questions/196258/… Commented May 22, 2017 at 11:48

1 Answer 1

2

You could use a tikz matrix:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning, fit}

\begin{document}
    \begin{equation}
    \begin{tikzpicture}[baseline=-1ex] 
    \matrix[%
        matrix of math nodes,
        nodes in empty cells,
        left delimiter={[},right delimiter={]}, 
        inner xsep=2pt, column sep=8pt, 
        ] (m)
    {%
        \mathbf {c_0}& & & \\
        &\mathbf {c_1 }& & \\[-8pt]
        & & \ddots & \\
        && &\mathbf {c_{r-1}} \\[4pt]
        && &\\
    };
    \node[font=\scriptsize, above right= -5pt and 4pt of m.south east] {$(n+1)(r+1)\times4r$};
    \node[rectangle, draw, fit={(m-1-1) (m-2-1)}, inner sep=0pt, text width=22pt] {}; 
    \node[rectangle, draw, fit={(m-2-2) (m-3-2)}, inner sep=0pt, text width=22pt] {}; 
    \node[rectangle, draw, fit={(m-4-4) (m-5-4)}, inner sep=0pt, text width=22pt] {}; 
    \end{tikzpicture}
    \end{equation}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .