Consider the following MWE:
\documentclass[varwidth,tightpage,border=1bp]{standalone}
\usepackage{tikz}
\pagecolor{yellow!15} % ignored with preview, but not w/ varwidth
\begin{document}
\begin{tikzpicture}
\tikzset{/tikz/line width=1cm} % no effect
\draw %[/tikz/line width=1cm] % has effect here
(0,0) -- ++(1,0)
node[fill,scale=0.5](A){};
\pgfkeysgetvalue{/tikz/line width}{\tmp}
\typeout{tmpX \tmp \meaning\tmp}
\end{tikzpicture}
\end{document}
My first question is: here I'm trying to \tikzset{/tikz/line width=1cm}
, but it has no effect (only on document size); the output is:
If I use the \draw[/tikz/line width=1cm]
, then there is effect, and the output is:
So, the question is - how come /tikz/line width
doesn't have any effect? I would have thought it is a "master" key/variable of sorts (which kicks in, if nothing else is specified).
But even more important for me is - how do I read tikz
/pgf
keys? As you can see, I'm trying with \pgfkeysgetvalue{/tikz/line width}{\tmp}
, but when I try to print it to stdout, I get this:
tmpX \tmp \relax
... which means that \tmp
in unexpandable, probably because it has been "let" to \relax
; and so I cannot read any information in /tikz/line width
.
So, how can I read TikZ/PGF keys - in an expandable format, so I can use them in code?
EDIT: After reading Simple example of pgfkeys, I simply tried .initial
:
\tikzset{/tikz/line width/.initial=1cm}
... and afterwards, the stdout printout is:
tmpX 1cmmacro:->1cm
... which means my syntax for reading keys was correct - but apparently, the key /tikz/line width
did not exist, even if I tried to "set" it?!
My question then becomes - what controls the line width of the \draw
in the case when we do not specify anything, and how can I find and print the corresponding key values (if they exist)?
possibly related:
\tikzset{/tikz/<key>}
sets the key/tikz/tikz/<key>
either use\pgfkeys
or remove the/tikz/
\tikzset{line width/.initial=1cm}
to get an effect as described in the OP... Cheers!line width
doesn't hold a value. Instead it sets the length\pgflinewidth
. You might want to read that dimen instead of reading a key because the dimen can change without changing the key value.