![특정 터미널 노드를 따르는 모든 노드 색상 지정](https://rvso.com/image/420022/%ED%8A%B9%EC%A0%95%20%ED%84%B0%EB%AF%B8%EB%84%90%20%EB%85%B8%EB%93%9C%EB%A5%BC%20%EB%94%B0%EB%A5%B4%EB%8A%94%20%EB%AA%A8%EB%93%A0%20%EB%85%B8%EB%93%9C%20%EC%83%89%EC%83%81%20%EC%A7%80%EC%A0%95.png)
나는 채워진 점으로 일부 노드를 색칠하려고 노력해 왔습니다. 하지만 포레스트 패키지 지침에 따라 첫 번째와 두 번째 행만 채울 수 있어서 막혔습니다.
내가 하려는 일:
첫 번째와 두 번째만 할 수 있었어요. 내 최소한의 코드는 다음과 같습니다.
\documentclass[border=3mm]{standalone}
\usepackage[linguistics,edges]{forest}
\forestset{
ned/.style={%
for tree={calign=fixed edge angles},
delay={%
where content={}{%
shape=coordinate,
for nodewalk={%
Nodewalk={%
on invalid=fake,
}{%
parent,
}{%
for children={anchor=north},
}
}{},
}{},
},
},
}
\begin{document}
\begin{forest}
ned
[DP
[
[
[pro]
[
[VP
[NP\\ t\textsubscript{1}]
[V\\Tuttukları]
]
[T]
]
]
[C]
]
[
[NP\\aşçı]
[D]
]
]
\path[fill=red] (.parent anchor) circle[radius=2pt];
\path[fill=red] (!1.child anchor) circle[radius=2pt];
\end{forest}
\end{document}
답변1
이해하기 쉽도록 노드당 하나의 색상을 선택했습니다(필요에 따라 빨간색으로 변경할 수 있습니다).
위에서 아래로:
\path[fill=red] (.parent anchor) circle[radius=2pt];
\path[fill=black] (!1.child anchor) circle[radius=2pt];
\path[fill=green] (!11.child anchor) circle[radius=2pt];
\path[fill=blue] (!112.child anchor) circle[radius=2pt];
\path[fill=yellow] (!1121.south) circle[radius=2pt];
\path[fill=orange] (!11212.child anchor) circle[radius=2pt];
MWE:
\documentclass[border=3mm]{standalone}
\usepackage[linguistics,edges]{forest}
\forestset{
ned/.style={%
for tree={calign=fixed edge angles},
delay={%
where content={}{%
shape=coordinate,
for nodewalk={%
Nodewalk={%
on invalid=fake,
}{%
parent,
}{%
for children={anchor=north},
}
}{},
}{},
},
},
}
\begin{document}
\begin{forest}
ned
[DP
[
[
[pro]
[
[VP
[NP\\ t\textsubscript{1}]
[V\\Tuttukları]
]
[T]
]
]
[C]
]
[
[NP\\aşçı]
[D]
]
]
\path[fill=red] (.parent anchor) circle[radius=2pt];
\path[fill=black] (!1.child anchor) circle[radius=2pt];
\path[fill=green] (!11.child anchor) circle[radius=2pt];
\path[fill=blue] (!112.child anchor) circle[radius=2pt];
\path[fill=yellow] (!1121.south) circle[radius=2pt];
\path[fill=orange] (!11212.child anchor) circle[radius=2pt];
\end{forest}
\end{document}
내 생각에는 그것이 자명하다고 생각합니다. 그렇지 않으면 알려주세요.