\documentclass{article}
\usepackage[margin=.8in]{geometry}
\usepackage{forest}
\usepackage{tikz}
\begin{document}
\begin{forest} baseline, for tree={anchor=center, align=center, l sep+=0em, s sep+=0em} myGP1/.style={
GP1}
[
[$\sigma$ [C [f]] [V [u]]]
[$\sigma$ [C [m]] [V [e]] [C[N]]]
]
\end{forest}
\end{document}
你好,我正在尝试使用 Forest Package(带有 GP1 样式)绘制音节(CV 骨架),我该如何绘制没有红框中两个分支的树?
答案1
分离forest
s?
\documentclass{article}
\usepackage[margin=.8in]{geometry}
\usepackage{forest}
%\usepackage{tikz} % loaded by forest
\begin{document}
\begin{forest} baseline, for tree={anchor=center, align=center, l sep+=0em, s sep+=0em}
[$\sigma$ [C [f]] [V [u]]]
\end{forest}
\begin{forest} baseline, for tree={anchor=center, align=center, l sep+=0em, s sep+=0em}
[$\sigma$ [C [m]] [V [e]] [C[N]]]
\end{forest}
\end{document}
输出
如果你尝试使用该GP1
样式,你应该首先在以下网址下载:https://github.com/sasozivanovic/forest-styles/blob/master/forest-GP1.sty并按照以下示例使用它
\documentclass{article}
\usepackage[margin=.8in]{geometry}
\usepackage{forest-GP1}
%\usepackage{tikz} % loaded by forest
\begin{document}
\begin{forest} GP1, baseline, for tree={anchor=center, align=center, calign=center, l sep+=0em, s sep+=0.5em}
[
[$\sigma$ [C [f]] [V [u]]]
[$\sigma$ [C [m]] [V [e]] [C[N]]]
]
\end{forest}
\end{document}
输出
答案2
如果您只想要空根,而不想要样式的所有其他格式GP1
,则只需使用for root={phantom, for children={baseline}}
,它将根设置为空,并将树的基线重新定义为根子项的基线。下面我创建了一个unrooted
执行此操作的样式。
\documentclass{article}
\usepackage[margin=.8in]{geometry}
\usepackage{forest}
% \usepackage{tikz} % you don't need to load this separately since it's loaded by forest
\begin{document}
\forestset{unrooted/.style={for root={phantom, for children={baseline}}}}
(e.g., example number) % to show vertical alignment
\begin{forest} for tree={anchor=center, align=center, l sep+=0em, s sep+=0em}, unrooted
[
[$\sigma$ [C [f]] [V [u]]]
[$\sigma$ [C [m]] [V [e]] [C[N]]]
]
\end{forest}
\end{document}
附注:如果您希望分支到达音节节点下的某个点,则可以使用文档sn edges
第 8 页中定义的样式forest
。在这种情况下,您需要删除anchor=center
。