When answering questions here and when drawing my own complicated TikZ/PGF drawings, I've developed a fair number of "tips and tricks" for debugging the code. I'm sure that others have as well. I think it would be useful to accumulate a list of such, whence this question:
What are your tips and tricks for debugging TikZ/PGF code?
Note: in one sense this seems an obvious candidate for making Community Wiki as there is no single answer. However, I think that these tricks take some ingenuity and so deserve to gain their authors a modicum of reputation, whence I'm reluctant to make it a CW question (of course, I'll donate all my reputation gained from this question to a worthy cause). Once there are a fair few answers, I can see that organising them into a single CW answer would be a good thing, but that doesn't mean that the question should be CW. On the other hand, whilst in favour of it not being CW, I wouldn't be in anyway upset if the feeling was that it should be CW.
Best Answer
I'll start off with the
show node name
key. This is very useful when trying to work out why a complicated node name isn't working (often because a period has snuck in uninvited).Here's the code:
We add the
\show
code to the\tikz@mode
macro to ensure that the node name is set by the time we're called. Otherwise\node[show node name] (hello) {};
wouldn't work.