[Tex/LaTex] Forest trees: Reduce size of tree node

foresttikz-trees

I want to scale down some nodes of my tree. But I do not get them smaller. inner sep=0.01mm results in the same node size as inner sep=1mm. How is that possible? What do I miss?

enter image description here

My code:

\documentclass[border=10pt]{standalone} 

\usepackage{verbatim}
\usepackage{tikz}
\usepackage{forest}
\usepackage{graphicx}

\begin{document}
\begin{forest}
for tree={delay={where content={}{content={\phantom{00}}}{}},s sep+=5mm,l+=5mm}
[,circle,fill=black,inner sep=1mm
  [,circle,fill=red,inner sep=0.5mm
    [,circle,draw,black,inner sep=0.1mm]
    []
    [,circle,draw,black,inner sep=0.1mm]
    []
  ]
  []
  [,circle,fill=red,inner sep=0.5mm
    [,circle,fill=red,inner sep=0.25mm
        [,circle,draw,black,inner sep=0.1mm]
        [,circle,draw,black,inner sep=0.1mm]
        [,circle,draw,black,inner sep=0.1mm]
        [,circle,draw,black,inner sep=0.001mm]%%% <------------- ??
    ]
        []
        []
    [,circle,draw,black,inner sep=0.1mm] 
  ]
  [,circle,fill=red,inner sep=0.5mm]
]
\end{forest}
\end{document}

Best Answer

As Salim Bou pointed out in a comment, the reason the inner sep appears ineffective is that the content of the node itself is rather large, relatively speaking. So the difference between 0.1mm and 0.001mm makes little difference as that only changes the margin around the content from tiny to more tiny.

As Salim Bou suggested, one approach is to delete the code adding the content to the tree's nodes. In this case, the inner sep settings will actually determine the size of all nodes in the tree.

If you only want to adjust the size of that one node, however, you may prefer to override the content later. This will change only that node's content, if set as an argument for that node. Do note that most of the inner sep settings could be simply deleted in this case, with almost no visual affect on the appearance.

I'd also suggest making use of styles to avoid duplicating settings. How best to do this depends on what you need. Here's a possible example which also illustrates the two methods of altering the sizing explained above.

\documentclass[border=10pt]{standalone}
\usepackage{forest}

\begin{document}
\begin{forest}
  for tree={
    s sep'+=5mm,
    l'+=5mm,
  },
  my circle/.style={
    circle, fill=#1,
  },
  red circle/.style={
    my circle=red, inner sep=#1mm,
  },
  black circle/.style={
    my circle=black, inner sep=#1mm,
  },
  black hole/.style={
    circle, draw=black, inner sep=#1mm,
  }
  [, black circle=1
    [, red circle=0.5
      [, black hole=0.1]
      []
      [, black hole=0.1]
      []
    ]
    []
    [, red circle=0.5
      [, red circle=0.25
          [, black hole=0.1]
          [, black hole=0.1]
          [, black hole=0.1]
          [, black hole=0.001]
      ]
          []
          []
      [, black hole=0.1]
    ]
    [, red circle=0.5]
  ]
\end{forest}
\begin{forest}
  for tree={
    delay={where content={}{content={\phantom{00}}}{}},
    s sep'+=5mm,
    l'+=5mm,
  },
  my circle/.style={
    circle, fill=#1,
  },
  red circle/.style={
    my circle=red, inner sep=#1mm,
  },
  black circle/.style={
    my circle=black, inner sep=#1mm,
  },
  black hole/.style={
    circle, draw=black, inner sep=#1mm,
  }
  [, black circle=1
    [, red circle=0.5
      [, black hole=0.1]
      []
      [, black hole=0.1]
      []
    ]
    []
    [, red circle=0.5
      [, red circle=0.25
          [, black hole=0.1]
          [, black hole=0.1]
          [, black hole=0.1]
          [, black hole=0.001, before typesetting nodes={content=}]%%% <------------- ??
      ]
          []
          []
      [, black hole=0.1]
    ]
    [, red circle=0.5]
  ]
\end{forest}
\end{document}

two trees

The tree on the left shows the nodes with sizes determined by their inner seps. The tree on the right shows them with the phantom 00 as content, excepting the single tiny node where this is overridden.

Related Question