Sign up ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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