森林ツリー: ツリーノードのサイズを縮小する

森林ツリー: ツリーノードのサイズを縮小する

ツリーの一部のノードを縮小したいのですが、小さくなりません。inner sep=0.01mmは と同じノード サイズになりますinner sep=1mm。どうしてそうなるのでしょうか? 何が足りないのでしょうか?

ここに画像の説明を入力してください

私のコード:

\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}

答え1

としてサリム・ボウはコメントで指摘した。が効果的でないように見える理由はinner sep、ノード自体のコンテンツが、相対的に見てかなり大きいためです。したがって、 と の違いは0.1mmほとんど0.001mm意味がありません。コンテンツの周囲の余白が小さいものからさらに小さいものに変わるだけだからです。

Salim Bou が提案したように、1 つの方法は、ツリーのノードにコンテンツを追加するコードを削除することです。この場合、設定によってinner sepツリー内のすべてのノードのサイズが実際に決定されます。

ただし、その 1 つのノードのサイズだけを調整したい場合は、後でコンテンツを上書きすることをお勧めします。そのノードの引数として設定されている場合、これによりそのノードのコンテンツのみが変更されます。inner sepこの場合、ほとんどの設定は単に削除でき、外観にほとんど影響がないことに注意してください。

また、設定の重複を避けるためにスタイルを利用することをお勧めします。これを行う最善の方法は、必要なものによって異なります。ここでは、上で説明したサイズを変更する 2 つの方法も示す例を示します。

\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}

2本の木

左側のツリーには、 によってサイズが決定されたノードが表示されますinner sep。右側のツリーには、ファントムが00コンテンツとして表示されます (ただし、これがオーバーライドされる単一の小さなノードは除きます)。

関連情報