Difference between an option's default and its initial value

This answer is for explaining what the TikZ/PGF manual means for default/initial values of a keyword. It may or may not have any relation with the usage of .default and .initial keys depending on the specific implementation.

For example for shape:

  • no default means you can't say

     \node[shape, red]{...}
    

    because there is no default (in this case the key is defined so that it must have an argument, so it will error out if you do; thanks, @percusse). If, for example, it had circle as default, that means that you could have used the aforementioned command to have a circle-shaped node;

  • initial means that if you say

    \node[color=red] {...}
    

    without mentioning shape you'll have a rectangle.

Another example could be (straight from the manual):

/pgf/tips=value (default true, initially on draw) alias /tikz/tips

This key governs in what situations arrow tips are added to a path. The following values are permissible:

  • true (the value used when no value is specified)
  • proper
  • on draw (the initial value, if the key has not yet been used at all)
  • on proper draw
  • never or false (same effect)

[...]

(although I don't understand what the comment on the last item means --- just that never and false are the same?)


This is the case where it sounds like the problem is related to keys but shape is a pretty legacy keyword and the way it is defined is pretty straightforward.

\tikzoption{shape}{\edef\tikz@shape{#1}} 

(\tikzoption later became \tikzset. So don't use it)

Then at the initialization of TikZ package we see

\def\tikz@shape{rectangle}%

Note that this is the global scope so if you don't fiddle with it every TikZ picture will inherit this default value. This is not related to /.initial and /.default problem. It's the manual's classification that makes it looks like key issue.


In the manual if you see no default this means you need to supply a value. If you see no value then,... well... you don't need to provide a value. If you insist on providing a value sometimes you get an error, sometimes not.

Example,

\node[matrix of math nodes={4}{5}] {\tan \\ \sin};

will not error. Because every style/code handler intrinsically accepts arguments. If not explicitly set by /.value forbidden handler then nothing happens.

Initially <...> means if you don't provide anything else I'm going to use <...>.

As usual, exceptions apply...

One final note about TikZ/PGF difference. All TikZ is converted to PGF code so there are no separate functionalities. It's a matter of syntax.

Tags:

Tikz Pgf