# Matrix with arrows and labels

I would like your advice on writing a matrix with latex. In order to explain the meaning of the rows and columns, the matrix should be surrounded by two arrows, one on the left side pointing downward and one on the upper side pointing to the right. Where the arrows are labeled. I tried several things such as:

$M_{reg} = \bordermatrix{~ & 0 & 1 & 2 & 3 & 4 & \cr 0 & 0 & 0 & 0 & 1 & 1 \cr 1 & 0 & 0 & 1 & 1 & 1 \cr 2 & 0 & 0 & 1 & 1 & 0 \cr 3 & 0 & 0 & 1 & 1 & 0 \cr 4 \downarrow{Ca^{2+}} & 0 & 0 & 0 & 0 & 0 \cr %Ca^{2+} }^{\xrightarrow{DAG}}$


But it's not pretty and things are not correctly aligned. Do you have any ideas, or pointers to draw that matrix correctly ?

-

## 2 Answers

Another way with TikZ similar to Highlight elements in the matrix:

\documentclass{article}
\usepackage{tikz}
\newcommand{\tikzmark}[1]{\tikz[overlay, remember picture] \coordinate (#1);}
\begin{document}
$M_{reg} = \qquad \bordermatrix{~ & \tikzmark{harrowleft} 0 & 1 & 2 & 3 & 4\tikzmark{harrowright} \cr \tikzmark{varrowtop} 0 & 0 & 0 & 0 & 1 & 1 \cr 1 & 0 & 0 & 1 & 1 & 1 \cr 2 & 0 & 0 & 1 & 1 & 0 \cr 3 & 0 & 0 & 1 & 1 & 0 \cr \tikzmark{varrowbottom}4 & 0 & 0 & 0 & 0 & 0 \cr }$
\tikz[overlay,remember picture] {
\draw[->] ([yshift=3ex]harrowleft) -- ([yshift=3ex]harrowright)
node[midway,above] {\scriptsize DAG};
\draw[->] ([yshift=1.5ex,xshift=-2ex]varrowtop) -- ([xshift=-2ex]varrowbottom)
node[near end,left] {\scriptsize $Ca^{2+}$};
}
\end{document}


-
Awesome !!! Thanks a lot to both of you !! CLear and perfect – Albert Jan 9 '12 at 15:34

You can use TikZ to annotate the matrix.

\documentclass{article}
\usepackage{tikz}
\begin{document}
$M_{reg} = \bordermatrix{~ & 0 & 1 & 2 & 3 & \tikz[remember picture]\node[inner sep=0pt] (a) {4}; & \cr 0 & 0 & 0 & 0 & 1 & 1 \cr 1 & 0 & 0 & 1 & 1 & 1 \cr 2 & 0 & 0 & 1 & 1 & 0 \cr 3 & 0 & 0 & 1 & 1 & 0 \cr \tikz[remember picture]\node[inner sep=0pt] (b) {4}; & 0 & 0 & 0 & 0 & 0 \cr }$
\begin{tikzpicture}[overlay, remember picture]
\draw[->] (a.east) ++(2mm,0) -- node[above] {DAG} ++(1,0);
\draw[->] (b.south) ++(0,-2mm) -- node[right] {$Ca^{2+}$} ++(0,-1);
\end{tikzpicture}
\end{document}


The result:

There is an extra space between the last column and the closing parenthesis because you have an extra & on the first row. I left that in my code, because I though you might have a reason for it. If you don't you can just remove it and the spacing will be correct.

-
Thanks a lot ! That's a nice starting point ! Ideally, I would like to avoid the enumeration and have an arrow all above and on the left side of the matrix – Albert Jan 9 '12 at 15:22