In response to Ignasi's remark that he doesn't know what \pgfextra
does, it suspends path parsing or tracing so that an arbitrary code can be executed. This is risky or impossible otherwise. I demonstrate the use of an arbitrary code in the following.
After a lengthy trace, I saw that when using \pgfextra
it is necessary to avoid spurious spaces, such as the space after \pgfextra{
. Those spaces are not removed internally. Ignasi did it correctly in his solution, but it is easy to overlook. I hope PGF developers will attend to this internally later. In the meantime, when \pgfextra
comes in the argument of at end node
, the following solution can be used.
EDIT: I present the full code below in response to Altermundus' comment.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart,positioning}
\makeatletter
% If we load pgfkeyx.sty, we can normalize the list before parsing.
% Well, let's ignore difficult lists here.
% Using the delimiter \pgfeov for the callback of \pgfkeyscommaloop allows it
% to be multi-parametered.
\def\pgfkeyscommaloop#1#2{\pgfkeys@commaloop{#1}#2,\pgfkeyscommaloop,}
\def\pgfkeys@commaloop#1#2,{%
\expandafter\ifx\@car#2x\@nil\pgfkeyscommaloop
\expandafter\@gobble\else\expandafter\@iden\fi
{#1#2\pgfeov\pgfkeys@commaloop{#1}}%
}
\def\ifpgfkeydef#1{%
\ifcsname pgfk@#1/.@cmd\endcsname
% OK, the command is already in the hash table; no safeguard needed
% against filling the hash.
\expandafter\ifx\csname pgfk@#1/.@cmd\endcsname\relax
\expandafter\expandafter\expandafter\@secondoftwo
\else
\expandafter\expandafter\expandafter\@firstoftwo
\fi
\else
\expandafter\@secondoftwo
\fi
}
\def\pgfkey@def@do#1\pgfeov{\ifpgfkeydef{#1}{-1}{+0}}
\def\pgfkey@undef@do#1\pgfeov{\ifpgfkeydef{#1}{+0}{-1}}
% Given a list of keys, I want to know if at least one of them is defined:
\def\ifonepgfkeydef#1{%
\ifnum\numexpr\z@\pgfkeyscommaloop\pgfkey@def@do{#1}<\z@
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
% Given a list of keys, I want to know if at least one of them is undefined:
\def\ifonepgfkeyundef#1{%
\ifnum\numexpr\z@\pgfkeyscommaloop\pgfkey@undef@do{#1}<\z@
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\ifonepgfkeydef{/tikz/at end of node,/tikz/at end node}{%
\@latexerr{Key(s) '/tikz/at end of node' and/or
'/tikz/at end node' already exist}\@ehd
}{}
% The following acrobatics is just an academic exercise: Altermundus's approach
% is simpler and better:
\tikzset{at end of node/.code=
\begingroup
\def\pgf@@relax{\relax}%
\pgfkeys@spdef\reserveda{#1}%
\def\reservedb##1\pgfextra##2##3\pgf@nil{%
\ifx\pgf@@relax##2\else
\pgfkeys@spdef\reservedb{##2}%
\def\reservedc##1\pgfextra\pgf@@relax{##1}%
\edef\reserveda{\unexpanded{##1}\noexpand\pgfextra{\unexpanded
\expandafter{\reservedb}}\unexpanded\expandafter{\reservedc##3}}%
\fi
}%
\expandafter\reservedb\reserveda\pgfextra\pgf@@relax\pgf@nil
\edef\reserveda{\endgroup
\noexpand\pgfkeysalso{append after command=%
{\unexpanded\expandafter{\reserveda}}}%
}\reserveda
,
at end node/.style={at end of node={#1}}
}
\def\minorrect#1#2#3{%
\draw[rounded corners=#1] (\tikzlastnode.#2)
rectangle (\tikzlastnode.one split #3);
}
\makeatother
\begin{document}
\begin{tikzpicture}[cons/.style={%
rectangle split,
rectangle split horizontal,
rectangle split parts=2,
outer sep=0pt,
at end of node={
\pgfextra{
\minorrect{3pt}{south west}{north}%
\minorrect{10pt}{north east}{south}%
}%
}%
}%
]
\node[cons](aa){};
\node[cons](bb)[below left=of aa]{};
\node[cons](cc)[below right=of aa]{};
\draw[->,red] (aa.west) -| (bb.north);
\draw[->,blue] (aa.east) -| (cc.north);
\end{tikzpicture}
\end{document}
\cons
macro from that point of view. (However, nesting tikzpictures is fraught with difficulty and it can be better to find an alternative that doesn't involve nesting, such as percusse's suggestion).