MWE

MWE

다음 MWE는 설명서의 예를 기반으로 합니다 forest. 스타일 dot(기호 사이에 표시됨 %%%)은 트리의 점에 대한 스타일(주로 색상)을 지정하는 인수를 취한다고 가정됩니다. 명명된 색상에 대해서는 작동하지만 설정은 dot={draw=none}효과가 없습니다. 일반적으로 draw/ fillto를 설정하면 none경로를 색상 없이 그리거나 채우는 것으로 간주됩니다.

이 이상한 효과의 원인은 무엇입니까? 이것이 dot를 사용하여 정의된 사실과 관련이 있습니까 \tikz+?

MWE

\documentclass{standalone}
\usepackage{forest}
\forestset{
  declare toks={elo}{}, % Edge Label Options
  anchors/.style={anchor=#1,child anchor=#1,parent anchor=#1},
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  dot/.style={tikz+={\draw[#1] (.child anchor) circle[radius=1.5pt];}},
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  decision edge label/.style n args=3{
    edge label/.expanded={node[midway,auto=#1,anchor=#2,\forestoption{elo}]{\strut$\unexpanded{#3}$}}
  },
  decision/.style={if n=1
    {decision edge label={left}{east}{#1}}
    {decision edge label={right}{west}{#1}}
  },
  text/.style={plain content},
  decision tree/.style={
    for tree={
      s sep=0mm,l=5mm,
      if n children=0{anchors=north}{
        if n=1{anchors=south east}{anchors=south west}},
      math content,
      /tikz/font=\footnotesize,
    },
    anchors=south, outer sep=2pt,
    dot={fill=white},for descendants={dot={fill}},
    delay={for descendants={split option={content}{;}{decision,content}}},
  }
}
\begin{document}
\begin{forest} decision tree
  [N,plain content
    [x;I,dot={draw=none,fill=red}] % 'draw=none' doesn't work here
    [x;I,dot={draw=red,fill=none}] % 'fill=none' doesn't work here
  ]
  % 'draw=none' works fine below
  \draw[draw=none](!1.anchor)--(!2.anchor)node[midway,above]{$x$};
\end{forest}
\end{document}

산출

여기에 이미지 설명을 입력하세요

답변1

draw=nonetikz+스타일 에서와 마찬가지로 에서도 잘 작동합니다 dot.

\begin{forest}
  [abc, dot={draw=none, fill=red}
  ]
\end{forest}

빨간 점, 무승부

그러나 는 tikz와 동일하지 않습니다 tikz+. tikz+누적됩니다. 그러므로 당신이 말한다면

for descendants={%
  dot={fill},
},

그런 다음 현재 노드(여기서는 루트)의 모든 하위 항목에 대해 dot스타일이 인수로 실행되고 fill다음 명령이 나중에 사용할 목록에 추가됩니다.

\draw [fill] (.child anchor) circle [radius=1.5pt];

dot그런 다음 특정 노드에 다시 적용하면 dot해당 인수로 다시 실행됩니다. 예를 들어,

dot={draw=none, fill=red}

나중에 사용할 TikZ 명령 목록에 다음을 추가합니다.

\draw [draw=none, fill=red] (.child anchor) circle [radius=1.5pt];

이제 이 노드에서는 트리가 그려질 때 이 두 명령이 차례로 사용됩니다.

\draw [fill] (.child anchor) circle [radius=1.5pt];
\draw [draw=none, fill=red] (.child anchor) circle [radius=1.5pt];

첫 번째는 원을 검정색으로 그리고 채웁니다. 두 번째는 그려지지 않았지만 빨간색으로 채워진 또 다른 원을 정확히 같은 위치에 추가합니다. 따라서 출력에 표시되는 내용은 다음과 같습니다.원, 하나씩.

원하는 경우에만마지막의 사용이 효과적이려면 가 아닌 dot사용으로 정의를 변경하세요 . 그러나 will을 사용하면 모든 항목을 덮어씁니다.tikztikz+dot다른노드에 tikz/ tikz+/ 를 사용합니다 . +tikz이것이 문제가 되지 않는다면 해결책은 매우 간단합니다. 문제가 있는 경우 원하는 대로 작동하도록 하거나 모든 호출이 발생하도록 하려면 좀 더 연습해야 합니다 dot.~ 전에다른 추가 사항은 TikZ 명령 목록에 적용됩니다.

노드당 최대 1개의 도트 정책을 시행하는 간단한 경우에 대해 변경된 코드는 다음과 같습니다.

\documentclass[tikz,multi,border=10pt]{standalone}
\usepackage{forest}
\forestset{
  declare toks={elo}{}, % Edge Label Options
  anchors/.style={%
    anchor=#1,
    child anchor=#1,
    parent anchor=#1,
  },
  dot/.style={%
    tikz={%
      \draw [#1] (.child anchor) circle [radius=1.5pt];
    },
  },
  decision edge label/.style n args=3{
    edge label/.expanded={%
      node [midway, auto=#1, anchor=#2, \forestoption{elo}] {\strut$\unexpanded{#3}$}
    }
  },
  decision/.style={%
    if n=1{%
      decision edge label={left}{east}{#1},
    }{%
      decision edge label={right}{west}{#1},
    }
  },
  decision tree/.style={
    for tree={
      s sep=0mm,
      l=5mm,
      if n children=0{anchors=north}{
        if n=1{%
          anchors=south east,
        }{%
          anchors=south west,
        },
      },
      math content,
      font=\footnotesize,
    },
    anchors=south,
    outer sep=2pt,
    dot={%
      fill=white,
    },
    for descendants={%
      dot={fill},
    },
    delay={%
      for descendants={%
        split option={content}{;}{decision,content},
      },
    },
  }
}
\begin{document}
\begin{forest}
  decision tree
  [N, plain content
    [x;I, dot={draw=none, fill=red}
    ]
    [x;I, dot={draw=red, fill=none}
    ]
  ]
\end{forest}
\end{document}

노드당 하나의 점만 사용하세요!

관련 정보