# What are most important variables set at the beginning of a tikzpicture? of a scope?

I asked a lot of questions about nested tikzpicture environments and if I agree with Andrew and Martin that nesting TikZ pictures isn't a good idea, it's interesting to know why. I gave some examples where it looks possible to nest TikZ Pictures.

With this examples I discovered or created some useful macros like

1. \begin{pgfinterruptboundingbox} \end{pgfinterruptboundingbox} here
2. \useasboundingbox here
3. \pgfinterruptpicture \endpgfinterruptpicture
4. \ensuretikz by Martin here
5. \restorefont created by Martin here
6. \savecurrentboundingbox \restorecurrentboundingbox created by me here
7. \tikzifinpicture here
8. other

7) it's interesting because the definition is \pgfutil@ifundefined{filldraw}{#2}{#1}%.

These macros are useful to manage the bounding box and the font but perhaps other values are interesting to save and restore.

It's possible to look at the sources but it's not very easy for a lot of us. The aim of my question is to build reference answers to describe what are the variables set when tikz picture begins and what are the differences with a scope?

-
My english is .. my english so it's not very fine. I think that It would be interesting if someone could correct and reformat my question. –  Alain Matthes Mar 4 '12 at 23:15
Could you please link some of the questions you refer to? –  Tobi Mar 5 '12 at 1:15
yes you are right I forgot the links –  Alain Matthes Mar 5 '12 at 4:52
I'm glad you posted this question! (to whom it may concern) Although this is nominally asking for a "big list" and might not have a single correct answer, I'd like to argue strongly against the question being made CW as giving an answer will probably involve a fair bit of testing and work. It would be appropriate to have a single CW-answer that summarised the others for ease of reference. –  Loop Space Mar 5 '12 at 8:16
@AndrewStacey I've some difficulties to understand exactly your comment but I think I know what you suggest and I agree with you. how to do this? –  Alain Matthes Mar 5 '12 at 8:48

## Differences between scopes and tikzpictures

1. Mode of usage.

A scope can be used only if already in "TikZ mode". A tikzpicture starts the "TikZ mode".

The contents of a node is in text mode. How to typeset a picture inside a node?

2. Preservation of bounding box.

Summary: Scopes work hard to ensure that the bounding box of the scope is passed on correctly to the surrounding tikzpicture. A tikzpicture environment does not expect to be contained in another tikzpicture environment and so does not take sufficient care to ensure that the bounding box of the external environment is unaffected by the internal one.

Summary: The vertical position of a tikzpicture can be adjusted by setting the baseline option. This is done at the end of the picture and is done by setting a macro that is examined at the end (the delay is so that it can use a coordinate defined during the picture). This macro is not reset at the start of a picture so nested pictures inherit the setting from the outer picture.