0

OK, it may seem stupid, but I often have tikz nodes inside a tikz environment inside a tikz node.

When the outer node has parameter minimum width set to non zero, it appears the inner node inherits this setting:

\documentclass{article}

\usepackage{tikz}

\begin{document}
\tikzset{m/.style={draw, minimum width=2cm}}

\tikz\node[m]{(\tikz\node[fill=yellow]{Hello};]};

\tikz\node[m]{(\tikz\node[fill=blue, minimum width=0]{Hello};]};
\end{document}

While I know that color of the outer node is applied to the inner node, this does not fall under the qualification of "inheritance". Other common settings (fill, draw, text, inner sep, outer sep) don't seem to be inherited either.

Is this documented? Are there other settings behaving the same way? Is it avoidable without force-setting minimum width for the inner nodes?

Context

To give my question some substance, I define a command \textnode that transforms any text into a tikz node, allowing for easy highlighting, overlaying, etc.

  • 2
    Nesting tikzpicture environments is not supported. Period. If it works, that's happenstance and you can expect it to break with a future update. If you nest them, all bets are off. You just shouldn't do this. – cfr May 28 '17 at 20:46
  • Consider using tikzmark's \subnode if you need to mark nodes within nodes. Or \tikzmark outside tikzpictures, for arbitrary text. – cfr May 28 '17 at 20:53
  • @cfr Well, that's sad, because apart from that little glitch, everything works really fine. I think I will accept the risk to see it break in future version, thanks for the warning. – Christoph Frings May 28 '17 at 20:54
  • @cfr I'll have to read tikzmark's manual more thoroughly, havn't noticed that command. – Christoph Frings May 28 '17 at 20:56
  • 2
    Really, there are better ways of handling this. You really don't want to nest these environments. – cfr May 28 '17 at 20:56
  • 2
    \subnode is very easy to use and was designed for exactly what you want to do :-). – cfr May 28 '17 at 20:58

0 Answers0