![特定の終端ノードに続くすべてのノードを色分けする](https://rvso.com/image/420022/%E7%89%B9%E5%AE%9A%E3%81%AE%E7%B5%82%E7%AB%AF%E3%83%8E%E3%83%BC%E3%83%89%E3%81%AB%E7%B6%9A%E3%81%8F%E3%81%99%E3%81%B9%E3%81%A6%E3%81%AE%E3%83%8E%E3%83%BC%E3%83%89%E3%82%92%E8%89%B2%E5%88%86%E3%81%91%E3%81%99%E3%82%8B.png)
いくつかのノードを塗りつぶされたドットで色付けしようとしています。しかし、フォレスト パッケージのガイドラインに従って、最初の 2 行しか塗りつぶすことができず、行き詰まっています。
私がやろうとしていること:
私は最初と 2 番目しかできませんでした。これが私の最小限のコードです:
\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
理解しやすくするために、ノードごとに 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}
説明不要だと思いますが、そうでない場合はお知らせください。