7

How can I have the size of a mindmap node be calculated automatically by TikZ such that the text inside fits nicely inside? With inner sep=... I am able to have the height fit in such a way, but not the width. Btw.: I am using rectangles as nodes, not the standard circles.

\documentclass[tikz,border=5]{standalone}
\usetikzlibrary{mindmap}

\tikzset{
    every node/.append style={concept, rectangle, minimum size=0cm, inner sep=2mm}
}

\begin{document}

\begin{tikzpicture}[mindmap,text=white]
\node {O} child { node {A} };
\end{tikzpicture}

\end{document}
  • Please post a minimum working example (MWE). How are we to guess what you've done or how you've configured a non-standard mind map if you don't show us? – cfr Jan 2 '16 at 20:43
  • @cfr: I don't quite see the necessity in this case, but here you go. – Make42 Jan 2 '16 at 21:07
  • Well, it makes it much easier to answer. How else can I know what you've done? – cfr Jan 2 '16 at 21:42
  • I like the rectangular style. I never realised you can do this. Does it work with the gradual change of colour in connections between the nodes? I guess it should? I guess it would be nice if the transition to the connection could be smoother, though. It keeps reminding me of Dairy Milk ads. – cfr Jan 2 '16 at 21:48
7

I think you can simply add

text width=

to the style for every node. The mindmap style applies styles for each level of the tree which set the width of the text. You could override these separately per level, but if you want to do this generally, just adding it for all nodes seems to make more sense.

This produces

shrink-to-fit nodes

Code:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{mindmap}
\tikzset{
    every node/.append style={concept, text width=, rectangle, minimum size=0cm, inner sep=2mm},
}
\begin{document}
\begin{tikzpicture}[mindmap,text=white]
  \node {Orangutans} child { node {Aardvarks} child { node {Bees} } };
\end{tikzpicture}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.