乳胶森林中兄弟姐妹的间距

乳胶森林中兄弟姐妹的间距

在第一行中,中间的兄弟向侧面倾斜。我该如何将其置于中间?

\documentclass{article}
\usepackage{forest}
\begin{document}
\begin{forest}
[$expr$
    [$expr$
        [$term$
            [$term$ [$factor$ [\texttt{number} [$78$]]]]
            [$*$]
            [$factor$ [\texttt{number} [$20$]]]
        ]
    ]
    [$+$]
    [$expr$
        [$term$
            [$term$ [$factor$ [\texttt{number} [$5$]]]]
            [$*$]
            [$factor$ [\texttt{number} [$39$]]]
        ]
    ]
]
\end{forest}
\end{document}

在此处输入图片描述

答案1

看看以下建议是否适合您:

\documentclass{article}
\usepackage{forest}
\begin{document}
\begin{forest}
[\textit{expr}
    [\textit{expr}
        [\textit{term}
            [\textit{term} [\textit{factor} [\texttt{number} [$78$]]]]
            [$*$, before computing xy={s/.average={s}{siblings}}]
            [\textit{factor} [\texttt{number} [$20$]]]
        ]
    ]
    [$+$, before computing xy={s/.average={s}{siblings}}]
    [\textit{expr}
        [\textit{term}
            [\textit{term} [\textit{factor} [\texttt{number} [$5$]]]]
            [$*$,before computing xy={s/.average={s}{siblings}}]
            [\textit{factor} [\texttt{number} [$39$]]]
        ]
    ]
]
\end{forest}
\end{document}

在此处输入图片描述

相关内容