我怎样才能去掉边缘上用红色圆圈标记的 0?
代码:
\documentclass[tikz]{standalone}
\usepackage{forest}
\tikzset{el style/.style={midway, font=\scriptsize, inner sep=+1pt, auto=right}}
\forestset{angled/.style={
content/.expanded={\noexpand\textless\forestov{content}\noexpand\textgreater}}}
\begin{document}
\begin{forest}
for tree={parent anchor=south},
where n children={0}{tier=word}{
if={n==1}{% n == 1 means first child
edge label={node[el style]{0}}
}{
edge label={node[el style, swap]{1}}
}
}
%
[2n+4 [n [$\bar{1}$ [0]]]
[n+4 [n [$\bar{0}$ [10]]]
[4 [1 [d [110]]]
[3 [1 [c [1110]]]
[2 [1 [b[11110] ] ]
[1 [a [11111] ] ] ] ] ] ] ]
\end{forest}
\end{document}
答案1
你只能循环具有 2 个子节点的节点:
where n children={0}{tier=word}{},
where n children={2}{
for children={
if={n==1}{% n == 1 means first child
edge label={node[el style]{0}}
}{
edge label={node[el style, swap]{1}}
}
}
}{},