@cmhughes: Thanks. I know the answer(s) for this question are already out there as part of other specific questions and comments, at least part of them. Here I would like to have at least one complete and well written answer just for this point.
–
Martin Scharrer♦Apr 18 '12 at 8:50

2 Answers
2

I suggest keeping the old syntax,
\tikzstyle{my style}=[some options,...] since it is much easier to read and understand. The new syntax would be for the more "advanced"
users and library writers.

Answer of Till Tantau :

I'm a bit undecided on this.

First, for compatibility reasons \tikzstyle will be around indefinitely, so the real question is what will be better for new code.

The reason I'm trying to kick out the \tikzstyle is that I would like to encourage people to keep style settings as local as possible. So, normally, style definitions should be given at the beginning of a picture as in

Starting with pgfplots 1.1, \tikzstyle should no longer be used to set pgfplots options.

Although \tikzstyle is still supported for some older pgfplotsoptions, you should replace any occurance of \tikzstyle with \pgfplotsset{style name/.style={key-value-list}} or the
associated /.append style variant.

Then, on page 280:

Please note that it is not possible to use the TikZ-command \tikzstyle{stylename}=[]. This was possible in a previous version and is still supported for backwards compatibility. But in some cases, it may not work as expected.

TikZ and its underlying engine PGF have a powerful built-in module pgfkeys. It can also be used as a standalone package (via \usepackage{pgfkeys}) to manipulate options for other purposes.

No matter which command is used, therefore, every defined option goes to some instruction in the form of

\pgfkeys{/key family/key/.subkey = {value list} }

Since TikZ is the frontend of PGF engine, analogous to LaTeX and TeX, there is a default key family, tikz. For example, every tikzpicture when started already selects the tikz key family and internally the options are processed accordingly if not stated otherwise.

As we are mostly using TikZ commands, it is tedious to select the tikz key family every time we define a node option etc. so a shortcut serves well here which is the topic of this question. \tikzset command is defined as

% |\tikzset| is a shortcut to set keys that belongs to the tikz
% family.
\def\tikzset{\pgfqkeys{/tikz}}

Hence, \tikzset is a wrapper for Whatever is given next, belongs to the TikZ family.

Up to here, the key family part is handled and we can focus on key/.subkey part. There is not much that can be done without refering to the manual on this issue and the pgfkeys section is quite comprehensive. I will just emphasize that the most common two examples are mykey/.code and mykey/.style.

The subkey /.style is a collection or a catalogue of options to be processed whenever called for, such as "define the shape as circle and draw it then run some code and also put a label and fill it with yellow etc.". A style can also receive some parameters for example, the last example can be achieved by putting

which simply adds the arguments to the key. Note that, rectangle comes after circle and dominates the previous option, hence, the node becomes a red rectangle. The order of the style specifications matter.

Now, back to the question!! We have two options to give style specifications. Namely,

Both would lead to the same output however as we see that the \tikzstyle form is shorter to type in. Other than that, as far as I know there is no particular difference. For example, appending is simply done by putting a + sign next to = and also as shown below defining a default value is also quite convenient. However tikzstyle is only limited to this particular case and it's not applicable to other subkeys e.g. if you want to put a piece of code for some computation you can directly use

\tikzset{mystyle/.code={execute whatever is given here}}

but there is no \tikzcode similar to \tikzstyle to achieve this.

Hence, as Altermundus quoted, it's more of a shortcut.

For the interested, below is the code where these commands are defined. The relevant code is given in tikz.code.tex file at line 1143.

Very nice. Maybe add that you can set several keys within the same \tikzset command (\tikzset{my style/.style={...}, my second style/.style={...}, ...}), which is shorter than using \tikzstyle commands. And an added bonus of using \tikzstyle is that you can just cut and paste the same list of styles to the options of a tikzpicture or a scope, which I guess is what Till Tantau means by wanting to "encourage people to keep style settings as local as possible".
–
JakeApr 18 '12 at 10:44

@Jake Thanks. I agree with you but Altermundus pretty much covered these by quoting the man himself :) Feel free to edit anyway. Maybe we should make this CW.
–
percusseApr 18 '12 at 13:43