I am creating some pictures I want to use within nodes. When I use a \newcommand with an argument, extra space is added and I can't get rid of it.
\documentclass{article}
\usepackage{tikz}
\begin{document}
\newcommand{\foo}[1][3]{
\begin{tikzpicture}
\foreach \x in {0,1,...,#1}
\filldraw (\x,0) circle (0.2cm);
\end{tikzpicture}
}
\newcommand{\test}{
\begin{tikzpicture}
\foreach \x in {0,1,...,3}
\filldraw (\x,0) circle (0.2cm);
\end{tikzpicture}
}
\begin{tikzpicture}
\node at(0,0) [draw, rectangle, inner sep=0] {\foo};
\node at(0,-0.5) [draw, rectangle, inner sep=0] {\test};
\end{tikzpicture}
\end{document}

\newcommandyour current definition has 5 space tokens coming from the ends of line. – David Carlisle Mar 29 '12 at 12:53