Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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 ?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

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}

Matrix with arrows

share|improve this answer
    
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:

TikZ annotated matrix

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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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