With this minimal example


line width  = 5cm,
CC/.initial = 7cm
It doesn't works :\pgfkeysvalueof{/tikz/line width}

It works : \pgfkeysvalueof{/tikz/CC}

I can't get the value of line width, on the contrary of CC. Why? Is it because CC is stored like plain text and line width is not? How can I achieve my goal?

1 Answer 1


The shown difference has nothing to do with how \pgfkeysvalueof works. This macro simply expands to the given key, i.e. it is defined as \csname pgfk@#1\endcsname, so you get \pgfk@/tikz/CC and \pgfk@/tikz/line width (using \csname you can have spaces and other non-letters in the macro name).

The difference is in the way these keys were defined. The /tikz/line width got defined as .code={\tikz@semiaddlinewidth {#1}}. This defines a macro called \pgfk@/tikz/line width/.@cmd which holds that code and stores the values somewhere else. If you use the key PGF/TikZ (i.e., pgfkeys) checks if a .@cmd is defined and executes that code.

Now, /tikz/CC is defined using .initial which stores the 7cm value directly in in the key, i.e., in the macro \pgfk@/tikz/CC. You then can get the value again using \pgfkeysvalueof{/tikz/CC} which expands to this macro.

So, you can't just use \pgfkeysvalueof on arbitrary keys you didn't define yourself and hope they work. The internal implementation can be more complicated than a simple assignment. In the case of the line width I can help you. The final line width is stored in \pgflinewidth which is a dimension register, i.e., you can use it using a factor like 0.5\pgflinewidth.

  • Additionally, is there any way to get the line width of specific style, e.g. /tikz/very thin (although manual specifies it is 0.2pt in this case)?
    – ivankokan
    Jan 9, 2020 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.