In defining a new shape with \pgfdeclareshape, I have problems to add many anchors with the \foreach statement. Each anchor is defined with three arguments. In the example, the argument #1 is OK but the program complains with #2 and #3. How can I generate so many anchors with different keys with \foreach?
\documentclass[a4paper,landscape]{article}
\usepackage{tikz}
\usetikzlibrary{calc,arrows}
\usepackage{amsmath}
\usepackage[left=1cm,right=1cm]{geometry}
\pagestyle{empty}
\begin{document}
\makeatletter
% Define shapes
\pgfdeclareshape{PE}{
% Inherit from rectangle
\inheritsavedanchors[from=rectangle]
\inheritanchor[from=rectangle]{center}
\inheritanchorborder[from=rectangle]
% In the following I want to make many anchors with some loop. For example,
%\foreach \x/\Y/\z in {een/1/.7,ee/1/0,ees/1/-1}
%{\anchor{\x}{
% \pgf@process{\northeast}%
% \pgf@x=\y\pgf@x%
% \pgf@y=\z\pgf@y%
%}}
%However, while #1 is replaced but #2 and #2 are not.
%How can I use \foreach or TeX loop?
\anchor{een}{
\pgf@process{\northeast}%
\pgf@x=1\pgf@x%
\pgf@y=.7\pgf@y%
}
\anchor{ee}{
\pgf@process{\northeast}%
\pgf@x=1\pgf@x%
\pgf@y=0\pgf@y%
}
\anchor{ees}{
\pgf@process{\northeast}%
\pgf@x=1\pgf@x%
\pgf@y=-.7\pgf@y%
}
\anchor{se}{
\pgf@process{\northeast}%
\pgf@x=1\pgf@x%
\pgf@y=-1\pgf@y%
}
% Draw the rectangle box and the port labels
\backgroundpath{
% Rectangle box
\pgfpathrectanglecorners{\southwest}{\northeast}
%Add labels
%The following code doesn't work.
%\foreach \x/\y in {een,ee,ees}
% {
% \pgf@anchor@PE@\x
% \pgftext[at={\pgfpoint{\pgf@x}{\pgf@y}},x=-\pgfshapeinnerxsep,y=0]{\raisebox{-.75ex}{\y}}
% }
%\foreach \x/\y in {anchor@PE@een/een,\pgf@anchor@PE@ee/ee,\pgf@anchor@PE@ees/ees}
%{
% \x
% \pgftext[at={\pgfpoint{\pgf@x}{\pgf@y}},x=-\pgfshapeinnerxsep,y=0]{\raisebox{-.75ex}{\y}}
%}
}
\makeatother
\begin{tikzpicture}[>=stealth']
\tikzset{PE/port labels/.style={font=\sffamily\scriptsize}}
\tikzset{every PE node/.style={draw=blue,minimum width=2cm,minimum
height=3cm,very thick,inner sep=1mm,outer sep=0pt,cap=round}}
% Place PEs
\foreach \m in {0,...,3}
\node [shape=PE] (PE\m) at ($ 4*(\m,0)$) {};
\end{tikzpicture}
\end{document}

label=anchor:textinstead of hardcoding into the shape. – percusse Jul 31 '12 at 22:35