1

In order to understand the pgfkeys system in Tikz, I would like to print/visualize the key tree. A detailed documentation is given in the user manual, chapter “Key Management”.

Is this conveniently possible?

This would include querying and iterating the tree (possibly with something like lua) and naturally visualizing it with a tikz tree package. However, a log output would be equally fine. This is not about typesetting but understanding what is stored within the tree.

I see two motivations:

1. Debugging

I do not understand why in following example the second node for the second placement of mypic becomes red. I raised this in a separate question. Here I would like to see where the keys mynodestyle={text=orange,font=\relsize{2}} I provided are stored in the tree

\documentclass{standalone}
\usepackage{tikz,relsize}

\tikzset{
  mynodestyle/.style={text=red,font=\relsize{1}},
  pics/mypic/.style={code={%
       \node[mynodestyle] at (0,0)  {Hello};
       \node              at (0,-1) {I should not be in style.};
  }}
}

\begin{document}
  \begin{tikzpicture}

   \path (0,0)  pic {mypic};
   \path (0,-2) pic [mynodestyle={text=orange,font=\relsize{2}}] {mypic}; % Unexpected behavior

  \end{tikzpicture}  
\end{document}

enter image description here

However, @Schrödinger's cat states

(I would agree that TikZ should give an error because of the additional =... stuff but this does not happen.)

Also using

\pgfkeysvalueof{/tikz/mynodestyle}
\pgfkeysvalueof{/tikz/mynodestyle/.style}

\pgfkeysgetvalue{/tikz/mynodestyle/.style}{\myvalue}
\myvalue

did not help me.

2. Convenient Exploration

The documentation of pgf/tikz is quite lengthy. Furthermore, a PDF file format provides not the fastest means to navigate and list matches. Having a method to find/collect/grep options/keys and what the defaults are would be helpful. I could imagine that this would also be interesting for tools like texlab.

Related questions:

Hotschke
  • 5,300
  • 5
  • 33
  • 63
  • Ryan Reich at some point wrote a package to do this sort of thing, but it never made it to CTAN and I don't know if it's available anywhere. How do I debug pgfkeys? You might want to email Sašo Živanović who expressed some interest in maintaining it, although I don't see it in his GitHub. – Alan Munn Jun 04 '20 at 16:01
  • I think you should add some details to the question. What tree do you expect? One from which you can learn which keys are under /pgf and which under /tikz? Should the tree be based on the keys used in a certain document, or just some illustration? From what is written it is not clear to me whether @AlanMunn's link is really what you are asking. –  Jun 04 '20 at 18:32
  • @AlanMunn Thanks for pointing me to the question by Ryan Reich. As you already said, trace-pgfkeys is unfortunately not available. Only commented code in the forest package is using it. – Hotschke Jun 05 '20 at 07:53
  • 1
    According to pgfmanual sec 88.4.4 Defining Styles: Key handle <key>/.style sets things up so that whenever <key>=<value> is encountered in a key list, then the <key list>, with every occurrence of #1 replaced by value, is processed instead. You don't specify a #1 in mynodestyle/.style, so nothing happened when you write [mynodestyle={...}]. If you append a ,#1 after your <key list> of mynodestyle/.style, the code will work well. – ZhiyuanLck Jun 05 '20 at 08:11
  • @ZhiyuanLck Thank you for your comment. This was very helpful. – Hotschke Jun 05 '20 at 17:41
  • Setting up mynodestyle/.value forbidden will raise en error if you do mynodestyle={<stg>}. – Qrrbrbirlbel Aug 08 '22 at 09:24

0 Answers0