1

This question already has an answer here:

In the document I have to describe a series of transformations, made with a matrix. Each transformation works only on 2x2 or 1x1 block, so I want to visually select this block in the matrix like this:

pmatrix with a rectangle selected

I can type the matrix using the pmatrix environment, but I don't know, how to draw the rectangle. What is the best way to achieve this?

marked as duplicate by Werner, egreg, Svend Tveskæg, mafp, Martin Schröder Feb 12 '14 at 22:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    Perhaps the following is helpful/sufficient/duplicate: Highlight elements in the matrix – Werner Feb 12 '14 at 20:32
  • @Werner, the link you provided was indeed very helpful. I managed to edit the code, provided in the question you linked to do what I wanted. For the sake of reference I wrote thus obtained code in the answer below. Thank you. – fiktor Feb 12 '14 at 21:44
3

My question was indeed close to duplicate as was hinted by @Werner . For the sake of reference I provide the code, which draws what I wanted. The code was created after analyzing the answer, linked by @Werner.

\begin{tikzpicture}[baseline=(current bounding box.center)]
    \matrix [matrix of math nodes,left delimiter=(,right delimiter=)] (m)
    {
        \!1 & 0 & 0\!\!\! \\ \!0 & {P_\theta \otimes P} & 0\!\!\! \\ \!0 & 0 & 0\!\!\! \\
    };
    \draw (m-1-1.north west) -- (m-1-3.north west) -- (m-3-3.north west) -- (m-3-1.north west) -- (m-1-1.north west);
\end{tikzpicture}

The following code should be included in the preamble.

\usepackage{tikz}
\usetikzlibrary{arrows,matrix,positioning}

This gives the following.

the resulted image is good enough

Not the answer you're looking for? Browse other questions tagged or ask your own question.