숲나무: 나무 노드의 크기를 줄입니다.

숲나무: 나무 노드의 크기를 줄입니다.

내 트리의 일부 노드를 축소하고 싶습니다. 그러나 나는 그것들을 더 작게 만들지 않습니다. 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

처럼Salim Bou가 댓글에서 지적했습니다., 이 효과가 없는 이유 inner sep는 노드 자체의 콘텐츠가 상대적으로 크기 때문입니다. 따라서 콘텐츠 주변의 여백만 작은 것에서 더 작은 것으로 변경되므로 와 0.1mm의 차이는 거의 차이가 없습니다.0.001mm

Salim Bou가 제안한 것처럼 한 가지 접근 방식은 트리 노드에 콘텐츠를 추가하는 코드를 삭제하는 것입니다. 이 경우 inner sep설정에 따라 실제로 트리에 있는 모든 노드의 크기가 결정됩니다.

그러나 해당 노드의 크기만 조정하려는 경우 나중에 내용을 재정의하는 것이 좋습니다. 해당 노드에 대한 인수로 설정된 경우 해당 노드의 내용만 변경됩니다. 이 경우 대부분의 inner sep설정은 외관에 거의 영향을 주지 않고 간단히 삭제될 수 있습니다.

또한 설정 중복을 피하기 위해 스타일을 활용하는 것이 좋습니다. 이를 수행하는 가장 좋은 방법은 필요한 사항에 따라 다릅니다. 다음은 위에서 설명한 크기 조정을 변경하는 두 가지 방법을 보여주는 가능한 예입니다.

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

두 그루의 나무

왼쪽의 트리는 크기가 inner seps에 의해 결정되는 노드를 보여줍니다. 오른쪽 트리는 00이것이 재정의된 작은 노드 하나를 제외하고 팬텀을 콘텐츠로 표시합니다.

관련 정보