This question tries to expand upon the another both of which aim at providing a "Best" practices for tikz-pics or atleast a couple of how to examples clarifying some of the more advanced trickery that one may employ.
Requirements :
It typically makes sense to have a set of base dimensions for a pic. Allowing the user to alter these dimensions enables them to customize the pic in some small way. This is useful under various circumstances. TikZ collects the options for a pic into the pic actions
for commands reading \draw pic[PIC ACTIONS] {...}
. It would seem sensible to allow options specified within pic actions
to be passed through to a branch in the pgf tree, pick of any relevant keys and pass the remaining keys back up the tree to some other family that knows how to process them.
Code :
This questions takes the cleaner code from @LoopSpace, strips away the calligraphy code to focus upon handling pic actions
. I have tried four methods in the code which basically try to pass the keys into the correct branch and if they re not present pass them up the tree. Mostly I'm trying this against the .search also
handler.
\documentclass[tikz]{standalone}
\usetikzlibrary{calc,calligraphy}
\makeatletter
\def\inf@key#1{%
\pgfkeysvalueof{/tikz/infinity dimensions/#1}%
}
\tikzset{
% Dimensions
infinity dimensions/.is family,
infinity dimensions/width/.initial =1 em,
infinity dimensions/height/.initial=1 em,
infinity dimensions/upper target/.initial=0.2,
infinity dimensions/lower target/.initial=0.8,
infinity dimensions/.search also={/tikz, /pgf},
% Method 1
%infinity dimensions/.style={infinity dimensions/.cd,},
% Method 2
%infinity dimensions/.style={infinity dimensions/#1},
% Method 3
infinity dimensions/.style={infinity dimensions/.cd,#1},
% Method 4
%infinity dimensions/.style={@infinity dimensions/.list={#1}},
%@infinity dimensions/.style={/tikz/infinity dimensions/#1}
% Pic/Symbol
infinity symbol/.pic = {
% Method 1
%\draw[infinity dimensions, pic actions]
% Method 2
%\draw[infinity dimensions=pic actions]
% Method 3
\draw[infinity dimensions=pic actions]
% Method 4
%\draw[infinity dimensions={pic actions}]
let \p1=(0,0) in
(\p1) .. controls (-\inf@key{upper target}*\inf@key{width}, \inf@key{height}) and (-\inf@key{lower target}*\inf@key{width},-\inf@key{height}) ..
(\p1) .. controls ( \inf@key{lower target}*\inf@key{width}, \inf@key{height}) and ( \inf@key{upper target}*\inf@key{width},-\inf@key{height}) .. cycle;
},
}
\makeatother
\begin{document}
\begin{tikzpicture}
\draw pic[double] {infinity symbol};
\end{tikzpicture}
\begin{tikzpicture}
\draw pic[height=2em] {infinity symbol};
\end{tikzpicture}
\end{document}
Problem :
Method(s) 1 and 4 return an error stating that /tikz/height
does not exist. Method(s) 2 and 3 return an error stating that /tikz/infinity dimensions/pic actions
does not exist. It seems the code either jumps up a level to the /tikz
and /pgf
roots and fails to recognize something from the /tikz/infinity dimensions
branch or it fails to recognize pic actions
within the /tikz/infinity dimensions
.
Question :
How does one pass the pic actions
to some underlying style such that parts of that style may be set and that style options not covered by that style get passed back up to the /tikz
and /pgf
branches.
The simplest mechanism for this might be the use of the .search also
handlers, but my atempts with this seem to fail. Perhaps it is more complex and one really requires key filtering.
Background :
This question implies that pic actions
are limited in some way.
@Qrrbrbirlbel provides some alternate strategies but I haven't succeeded with any of them.
tqft/.unknown
andtqft/.style
are working together somehow. Though your.unknown
handler looks rather similar to that in the pgf manual where they explain the.search also
handler. I'll take another bash at it in the morning. A possibly related question.