使用 pst-tree 移动/对齐节点

使用 pst-tree 移动/对齐节点

以下代码生成了漂亮的树pst-trees。我必须给树的叶子添加光泽,所以我将表格环境放入其中并添加了光泽。问题是代码没有将节点对齐到顶部,而是将它们居中。这意味着 David 上方的 N 位于is和之间AUX。但它应该像左边的例子一样位于的高度is。这可能吗? 在此处输入图片描述

\documentclass{article}


\usepackage{pst-tree}

\psset{nodesep=5pt}
\psset{linewidth=0.5pt}

\makeatletter
\def\tree{\@ifnextchar[{\@tree}{\@tree[top]}}
\def\@tree[#1]#2#3{%
  \renewcommand\psedge{\ncdiag[arm=0,angleA=270,angleB=90,linewidth=.5pt]}
  \pstree[levelsep=*2.8ex,nodesep=3pt,treesep=.5cm]{\TR[name=#1]{\small #2}}{#3}}


\def\le{\@ifnextchar[{\@le}{\@le[lex]}}
\def\@le[#1]#2{\renewcommand\psedge{\ncdiag[arm=0,angleA=270,angleB=90,linewidth=.5pt]}
               \TR[name={#1}]{\begin{tabular}{@{}c@{}}#2\end{tabular}}}
\makeatother


\begin{document}


\tree[a]{IP}{%
  \tree{NP}{\tree{N$'$}{%
    \tree{N}{\le{David}}}}
  \tree[b]{I$'$}{%
    \tree[c]{I}{\le{is}}
    \tree[d]{VP}{\tree[e]{V$'$}{\tree[f]{V}{\le{yawning}}}}}}%
\hfill
\tree[a]{IP}{%
  \tree{NP}{\tree{N$'$}{%
    \tree{N}{\le{David\\David}}}}
  \tree[b]{I$'$}{%
    \tree[c]{I}{\le{is\\\textsc{aux}}}
    \tree[d]{VP}{\tree[e]{V$'$}{\tree[f]{V}{\le{yawning\\gloss}}}}}}%


\end{document}

答案1

只需将选项[t]$添加到tabular_环境中:

\documentclass{article}

\usepackage{pst-tree}

\psset{nodesep=5pt}
\psset{linewidth=0.5pt}

\makeatletter
\def\tree{\@ifnextchar[{\@tree}{\@tree[top]}}
\def\@tree[#1]#2#3{%
  \renewcommand\psedge{\ncdiag[arm=0,angleA=270,angleB=90,linewidth=.5pt]}
  \pstree[levelsep=*2.8ex,nodesep=3pt,treesep=.5cm]{\TR[name=#1]{\small #2}}{#3}}

\def\le{\@ifnextchar[{\@le}{\@le[lex]}}
\def\@le[#1]#2{\renewcommand\psedge{\ncdiag[arm=0,angleA=270,angleB=90,linewidth=.5pt]}
               \TR[name={#1}]{\begin{tabular}{@{}c@{}}#2\end{tabular}}}
\makeatother

\begin{document}

\tree[a]{IP}{%
  \tree{NP}{\tree{N$'$}{%
    \tree{N}{\le{David}}}}
  \tree[b]{I$'$}{%
    \tree[c]{I}{\le{is}}
    \tree[d]{VP}{\tree[e]{V$'$}{\tree[f]{V}{\le{yawning}}}}}}%
\hfill
\tree[a]{IP}{%
  \tree{NP}{\tree{N$'$}{%
    \tree{N}{\le{David\\David}}}}
  \tree[b]{I$'$}{%
    \tree[c]{I}{\le{is\\\textsc{aux}}}
    \tree[d]{VP}{\tree[e]{V$'$}{\tree[f]{V}{\le{yawning\\gloss}}}}}}%

\end{document}

在此处输入图片描述

相关内容