我正在尝试绘制一棵类似于下图的树(节点内容不同)。我的叶子非常宽,我需要通过“抬起”其他叶子来将它们紧密地靠在一起。
是否可以调整下面的代码,让我的叶子处于不同的层次上,从而更靠近彼此,如上图所示?
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
[{$r_{1,8} = p \bmod a_{1,8}$}
[{$r_{1,4} = r_{1,8} \bmod a_{1,4}$}
[{$r_{1,2} = r_{1,4} \bmod a_{1,2}$}
[{$r_{1,1} = r_{1,2} \bmod (x-1)$}
[{$v_1$} ]
]
[{$r_{2,2} = r_{1,2} \bmod (x-2)$}
[{$v_2$} ]
]
]
[{$r_{3,4} = r_{1,4} \bmod a_{3,4}$}
[{$r_{3,3} = r_{3,4} \bmod (x-3)$}
[{$v_3$} ]
]
[{$r_{4,4} = r_{3,4} \bmod (x-4)$}
[{$v_4$} ]
]
]
]
[{$r_{5,8} = r_{1,8} \bmod a_{5,8}$}
[{$r_{5,6} = r_{5,8} \bmod a_{5,6}$}
[{$r_{5,5} = r_{5,6} \bmod (x-5)$}
[{$v_5$} ]
]
[{$r_{6,6} = r_{5,6} \bmod (x-6)$}
[{$v_6$} ]
]
]
[{$r_{7,8} = r_{5,8} \bmod a_{7,8}$}
[{$r_{7,7} = r_{7,8} \bmod (x-7)$}
[{$v_7$} ]
]
[{$r_{8,8} = r_{7,8} \bmod (x-8)$}
[{$v_8$} ]
]
]
]
]
\end{forest}
\end{document}
稍后编辑:我已尝试以下操作。
首先,奇数和偶数的r_{i,i}
分层不同。
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
[{$r_{1,8} = p \bmod a_{1,8}$}
[{$r_{1,4} = r_{1,8} \bmod a_{1,4}$}
[{$r_{1,2} = r_{1,4} \bmod a_{1,2}$}
[{$r_{1,1} = r_{1,2} \bmod (x-1)$},tier=odd
[{$v_1$} ]
]
[{$r_{2,2} = r_{1,2} \bmod (x-2)$},tier=even
[{$v_2$} ]
]
]
[{$r_{3,4} = r_{1,4} \bmod a_{3,4}$}
[{$r_{3,3} = r_{3,4} \bmod (x-3)$},tier=odd
[{$v_3$} ]
]
[{$r_{4,4} = r_{3,4} \bmod (x-4)$},tier=even
[{$v_4$} ]
]
]
]
[{$r_{5,8} = r_{1,8} \bmod a_{5,8}$}
[{$r_{5,6} = r_{5,8} \bmod a_{5,6}$}
[{$r_{5,5} = r_{5,6} \bmod (x-5)$},tier=odd
[{$v_5$} ]
]
[{$r_{6,6} = r_{5,6} \bmod (x-6)$},tier=even
[{$v_6$} ]
]
]
[{$r_{7,8} = r_{5,8} \bmod a_{7,8}$}
[{$r_{7,7} = r_{7,8} \bmod (x-7)$},tier=odd
[{$v_7$} ]
]
[{$r_{8,8} = r_{7,8} \bmod (x-8)$},tier=even
[{$v_8$} ]
]
]
]
]
\end{forest}
\end{document}
其次,对偶数r_{i,i}
的和v_i
的分层也不同。
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
[{$r_{1,8} = p \bmod a_{1,8}$}
[{$r_{1,4} = r_{1,8} \bmod a_{1,4}$}
[{$r_{1,2} = r_{1,4} \bmod a_{1,2}$}
[{$r_{1,1} = r_{1,2} \bmod (x-1)$},tier=odd
[{$v_1$},tier=last ]
]
[{$r_{2,2} = r_{1,2} \bmod (x-2)$}
[{$v_2$},tier=last ]
]
]
[{$r_{3,4} = r_{1,4} \bmod a_{3,4}$}
[{$r_{3,3} = r_{3,4} \bmod (x-3)$},tier=odd
[{$v_3$},tier=last ]
]
[{$r_{4,4} = r_{3,4} \bmod (x-4)$}
[{$v_4$},tier=last ]
]
]
]
[{$r_{5,8} = r_{1,8} \bmod a_{5,8}$}
[{$r_{5,6} = r_{5,8} \bmod a_{5,6}$}
[{$r_{5,5} = r_{5,6} \bmod (x-5)$},tier=odd
[{$v_5$},tier=last ]
]
[{$r_{6,6} = r_{5,6} \bmod (x-6)$}
[{$v_6$},tier=last ]
]
]
[{$r_{7,8} = r_{5,8} \bmod a_{7,8}$}
[{$r_{7,7} = r_{7,8} \bmod (x-7)$},tier=odd
[{$v_7$},tier=last ]
]
[{$r_{8,8} = r_{7,8} \bmod (x-8)$}
[{$v_8$},tier=last ]
]
]
]
]
\end{forest}
\end{document}
答案1
是的。就是这样tier
s 的用途。(如果你懂德语,你就会明白为什么我有选择murmel
。;-)
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
[{$r_{1,8} = p \bmod a_{1,8}$}
[{$r_{1,4} = r_{1,8} \bmod a_{1,4}$}
[{$r_{1,2} = r_{1,4} \bmod a_{1,2}$}
[{$r_{1,1} = r_{1,2} \bmod (x-1)$}
[{$v_1$},tier=murmel ]
]
[{$r_{2,2} = r_{1,2} \bmod (x-2)$},tier=murmel
[{$v_2$} ]
]
]
[{$r_{3,4} = r_{1,4} \bmod a_{3,4}$}
[{$r_{3,3} = r_{3,4} \bmod (x-3)$}
[{$v_3$},tier=murmel ]
]
[{$r_{4,4} = r_{3,4} \bmod (x-4)$},tier=murmel
[{$v_4$} ]
]
]
]
[{$r_{5,8} = r_{1,8} \bmod a_{5,8}$}
[{$r_{5,6} = r_{5,8} \bmod a_{5,6}$}
[{$r_{5,5} = r_{5,6} \bmod (x-5)$}
[{$v_5$},tier=murmel ]
]
[{$r_{6,6} = r_{5,6} \bmod (x-6)$},tier=murmel
[{$v_6$} ]
]
]
[{$r_{7,8} = r_{5,8} \bmod a_{7,8}$}
[{$r_{7,7} = r_{7,8} \bmod (x-7)$}
[{$v_7$},tier=murmel ]
]
[{$r_{8,8} = r_{7,8} \bmod (x-8)$},tier=murmel
[{$v_8$} ]
]
]
]
]
\end{forest}
\end{document}
v_i
附录:所有的都处于同一级别,但上方节点的级别交替的版本。
\documentclass{standalone}
\usepackage{forest}
\tikzset{bullet/.style={circle,fill,inner sep=0.2pt,outer sep=0pt}}
\begin{document}
\begin{forest}
[{$r_{1,8} = p \bmod a_{1,8}$}
[{$r_{1,4} = r_{1,8} \bmod a_{1,4}$}
[{$r_{1,2} = r_{1,4} \bmod a_{1,2}$}
[{$r_{1,1} = r_{1,2} \bmod (x-1)$},tier=faul
[{$v_1$},tier=murmel ]
]
[,bullet,tier=faul
[{$r_{2,2} = r_{1,2} \bmod (x-2)$},tier=schnabel
[{$v_2$},tier=murmel ]
]
]
]
[{$r_{3,4} = r_{1,4} \bmod a_{3,4}$}
[{$r_{3,3} = r_{3,4} \bmod (x-3)$},tier=faul
[{$v_3$},tier=murmel ]
]
[,bullet,tier=faul
[{$r_{4,4} = r_{3,4} \bmod (x-4)$},tier=schnabel
[{$v_4$},tier=murmel ]
]
]
]
]
[{$r_{5,8} = r_{1,8} \bmod a_{5,8}$}
[{$r_{5,6} = r_{5,8} \bmod a_{5,6}$}
[{$r_{5,5} = r_{5,6} \bmod (x-5)$},tier=faul
[{$v_5$},tier=murmel ]
]
[,bullet,tier=faul
[{$r_{6,6} = r_{5,6} \bmod (x-6)$},tier=schnabel
[{$v_6$},tier=murmel ]
]
]
]
[{$r_{7,8} = r_{5,8} \bmod a_{7,8}$}
[{$r_{7,7} = r_{7,8} \bmod (x-7)$},tier=faul
[{$v_7$},tier=murmel ]
]
[,bullet,tier=faul
[{$r_{8,8} = r_{7,8} \bmod (x-8)$},tier=schnabel
[{$v_8$},tier=murmel ]
]
]
]
]
]
\end{forest}
\end{document}
答案2
我认为您可以稍微调整一下子l
叶子的规范。例如,此代码不会生成最“美观”的树,但它似乎朝着您需要的方向迈进了一步。有关叶子放置的更多详细信息,请参阅文档(例如第 10 页)
\documentclass{standalone}
\usepackage{forest}
\begin{document}
\begin{forest}
[{$r_{1,8} = p \bmod a_{1,8}$}
[{$r_{1,4} = r_{1,8} \bmod a_{1,4}$}
[{$r_{1,2} = r_{1,4} \bmod a_{1,2}$}
[{$r_{1,1} = r_{1,2} \bmod (x-1)$}, l = 22mm,
[{$v_1$} ]
]
[{$r_{2,2} = r_{1,2} \bmod (x-2)$}, l = 12mm,
[{$v_2$}, l = 15mm ]
]
]
[{$r_{3,4} = r_{1,4} \bmod a_{3,4}$}
[{$r_{3,3} = r_{3,4} \bmod (x-3)$}, l = 22mm,
[{$v_3$} ]
]
[{$r_{4,4} = r_{3,4} \bmod (x-4)$}, l = 12mm,
[{$v_4$}, l = 15mm ]
]
]
]
[{$r_{5,8} = r_{1,8} \bmod a_{5,8}$}
[{$r_{5,6} = r_{5,8} \bmod a_{5,6}$}
[{$r_{5,5} = r_{5,6} \bmod (x-5)$}, l = 22mm,
[{$v_5$} ]
]
[{$r_{6,6} = r_{5,6} \bmod (x-6)$}, l = 12mm,
[{$v_6$}, l = 15mm ]
]
]
[{$r_{7,8} = r_{5,8} \bmod a_{7,8}$}
[{$r_{7,7} = r_{7,8} \bmod (x-7)$}, l = 22mm,
[{$v_7$} ]
]
[{$r_{8,8} = r_{7,8} \bmod (x-8)$}, l = 12mm,
[{$v_8$}, l = 15mm ]
]
]
]
]
\end{forest}
\end{document}