21

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?

Alain Matthes
  • 95,075
  • 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 04 '12 at 23:15
  • Could you please link some of the questions you refer to? – Tobi Mar 05 '12 at 01:15
  • yes you are right I forgot the links – Alain Matthes Mar 05 '12 at 04:52
  • 1
    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. – Andrew Stacey Mar 05 '12 at 08: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 05 '12 at 08:48
  • @Altermundus I could envision some calls for this to be made CW and I wanted to register my disagreement beforehand. That's the first part. For the second, that can be done anytime and, for technical reasons, it's best if it is done by someone who isn't you. So once someone posts something, I - or someone else - can start off the summary CW answer. (Actually, I could start by linking to my answer at the bounding box question.) – Andrew Stacey Mar 05 '12 at 08:54
  • @AndrewStacey I never work with "community wiki" so I'm confused technically. Do I need to change something to my question ? If yes perhaps to make something clean, it would be interesting to delete my question and that "you" do something more cleaner ? – Alain Matthes Mar 05 '12 at 09:12
  • @Altermundus No, you don't need to do anything. I've now done all that I proposed. I might have a go at editing the question a little, but only to clarify things a little and that's orthogonal to the community wiki aspect. – Andrew Stacey Mar 05 '12 at 09:18
  • @AndrewStacey ok I need to read a little more the faq :) – Alain Matthes Mar 05 '12 at 09:26

1 Answers1

13

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.

    More information: See this answer to Problem with overlay when a tikzpicture is inside another tikzpicture

  3. Inheritance of baseline.

    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.

    More Information: See TikZ: [baseline] interferes with blur shadow on background layer


Note about this answer: this answer is intended to be a summary of information about this matter. Please do not post detailed information here but link to it. However, please ensure that the information is on this site somewhere. So if it is in an existing answer, summarise it in this answer and link to the more detailed answer. If not, add a new answer to this question (not Community Wiki) with the details and add a summary here. This answer is Community Wiki to make it easy to add to. Other answers to this question need not be so.

Andrew Stacey
  • 153,724
  • 43
  • 389
  • 751