Sorry the code below for my minimal example is a bit long. In this code I defined two macros : the first macro \SC draws semi-circle and the second macro \ARC draws arcs. The first macro uses the second one.

\SC uses some options like radius and diameter. I need to use /SCopt/.search also={/tikz} if I want some keys from tikz.

\ARC uses some options too like through and angle but here only through is used.

My english is not perfect so I don't understand the subtleties of the pgfkeys section in the pfgmanual. My problem is how to manage the keys and the paths of \pgfkeys{/ARCopt/.cd,....

If I do not use

/ARCopt/.unknown/.code     = {\let\searchname=\pgfkeyscurrentname

I can't use the key diameter and I get

Error: I do not know the key '/tikz/diameter'.

It's normal this is a key of the first macro \SC but in this case I can use blue and not color=blue with /ARCopt/.search also={/tikz} (thanks to Paul Gaborit)

The question is : it is possible to get the two possibilities : unknown keys in the second macro and keys from pgf/tikz ?


\def\SCR(#1,#2){% semi circle with radius defined by 2 pts
    \coordinate (LastPT) at (barycentric cs:#2=1,#1=-2)  ;
    \coordinate (CenterPT) at (#1);
    \coordinate (StartPT) at (#2); 
\def\SCD(#1,#2){% semi circle with diameter defined by 2 pts
    \coordinate (CenterPT) at (barycentric cs:#1=1,#2=1)  ;
    \coordinate (StartPT) at (#1);
    \coordinate (LastPT) at (#2);}
        opt/.is choice,
        opt/diameter/.code    =\def\num{1},
        opt/radius/.code      =\def\num{0},
        opt/.default =radius,
        /SCopt/.search also={/tikz}
        \SCR(#2) % semi circle with radius defined by 2 pts
    \or% 1
        \SCD(#2)  % semi circle with diameter defined by 2 pts
        type/.is choice,
        type/through/.code      =   \def\numa{0},
        type/angle/.code        =   \def\numa{1},
        type/.default           =   through,
        through/.style          =   {type=through},% to avoid "type ="
        angle/.style            =   {type=angle},
        /ARCopt/.unknown/.code     = {\let\searchname=\pgfkeyscurrentname
        %/ARCopt/.search also={/tikz},
        \ARCT[#1](#2) % arc with only pts
    \or% 1
        \ARCA[#1](#2)  % arc with 2 pts and one angle

    \let\ra\pgfmathresult                       %it's the radius
                               \pgfpointanchor{#3}{center}}  %first angle
                               \pgfpointanchor{#4}{center}}  %last angle
    \draw[shift = {(#2)},/ARCopt/.cd,#1] (\fa:\ra pt) arc (\fa:\la:\ra pt);}

% not defined

\begin{tikzpicture}[point/.style={circle,minimum size=4pt,
    inner sep=0pt,outer sep=0pt,fill=black}]
    \path coordinate[point] (A) at (0,0)
          coordinate[point] (B) at (6,0)        
          coordinate[point] (C) at (4,0);


enter image description here

  • I found a solution but I don't like it . In \pgfkeys{/ARCopt/.cd, ... I added a fake key with type/diameter/.code ={},diameter/.style={type=diameter}, and at the end I used only /ARCopt/.search also={/tikz}. The problem is that I need to do this for all the keys of \SC not used in \ARC. Apr 29, 2016 at 12:19
  • Perhaps someone knows a good tutorial about pgfkeys with some examples ? Apr 29, 2016 at 12:22
  • Bad solution because if several macros use the same (sub) macro, it's very difficult to manage the keys Apr 29, 2016 at 21:05
  • After a look at tex.stackexchange.com/q/34376/86 I tried type/.unknown/.style = {} , The code compiles but I need an explanation or the good way to do this Apr 30, 2016 at 12:38

1 Answer 1


Perhaps my original answer is not clear.

You can replace

    /ARCopt/.unknown/.code     = {\let\searchname=\pgfkeyscurrentname


    /ARCopt/.search also    =   {/SCopt,/tikz},

Since in the definition of /SCopt it searches also /tikz, it should be equivalent to say

    /ARCopt/.search also    =   {/SCopt},

But then color=red fails. I do not know why.

On the other hand, if you remove

    /SCopt/.search also={/tikz},

then TeX complains that color unknown key. This is really undesired.

The argument of `.search also` is a **list** of paths. That is to say, you can `.search also` a hundred paths, including `/pgf`, `/tikz`, `/ARCopt`, `/SCopt`, and whatever you want. In your case, what you need is `/ARCopt/.search also={/SCopt}` because that is where you defined `diameter`.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .