Q:

TikZ compiles in body, but not as command

Possible Duplicate:
Problem with defining shortcuts for TikZ matrices. 

When I use the code below to draw a tikzpicture in the body of my document, it works just fine. However, when I define a command and try to use it, I get a Missing $ inserted error.
\documentclass[11pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{matrix, shapes, backgrounds}
\newcommand{\matrixa}{ 
\begin{tikzpicture}[>=latex]
\matrix (A) [matrix of math nodes,%
         left delimiter  = (,%             
         right delimiter = )] at (0,0) {%
         \cdot & \cdot  & \cdot  \\
          \cdot & \cdot  & \cdot  \\
          \cdot & \cdot  & \cdot  \\
           \\ };%     
         \end{tikzpicture}}
\begin{document}
\matrixa
\end{document}

A:

In this case you have to use a replacement for the ampersand:
\documentclass[11pt]{amsart}
\usepackage{tikz}
\usetikzlibrary{matrix, shapes, backgrounds}
\newcommand{\matrixa}{%
  \begin{tikzpicture}[>=latex]
  \matrix (A) [matrix of math nodes,
    left delimiter  = (,
    ampersand replacement=\&,
    right delimiter = )] at (0,0)
    {
     \cdot \& \cdot \& \cdot \\
     \cdot \& \cdot \& \cdot \\
     \cdot \& \cdot \& \cdot \\
    };
  \end{tikzpicture}}
\begin{document}
\matrixa
\end{document}

It's not necessarily \&, but this is usually chosen.

