垂直和水平对齐(更新的问题/评论中的问题)

垂直和水平对齐(更新的问题/评论中的问题)

我必须排版包含巨大 AVM 的树:

在此处输入图片描述

我想这样做forest,其想法是让所有右节点都与右边缘对齐,就像上图中手工完成的那样。理想情况下,这应该是树中一个节点的规范,并且应该影响该节点下方的所有内容。

我所拥有的是以下内容:

\documentclass{article}
\usepackage{graphicx}
\usepackage{forest}

\forestset{.style={for tree={parent anchor=south, child anchor=north,align=center,base=top}}}



\usepackage{array}


\makeatletter

\def\ibox#1{\mbox{}\setbox2=\hbox{$\scriptstyle #1$}\lower.2ex\vbox{\hrule
        \hbox{\vrule\kern1.25pt 
        \vbox{\kern1.25pt\box2\kern1.25pt}\kern1.25pt\vrule}\hrule}}


\newcommand{\sliste}[1]{%
\mbox{%
$\left\langle\mbox{\upshape\scshape #1}\right\rangle$}%
}

\newcommand{\liste}[1]{%
\mbox{%
$%
\left\langle\begin{tabular}{@{}>{\upshape\scshape}l@{}}#1\end{tabular}\right\rangle%
$%
%\\[-1.5mm]
}%
}


\newcommand{\phonliste}[1]{%
\mbox{%
$%
%
\left\langle \mbox{\normalfont\itshape#1} \right\rangle%
$%
%\\[-1.5mm]
}%
}


\setlength{\extrarowheight}{1pt}

\def\ms{\futurelet\msLook\msdecide}
\def\msdecide{\ifx\msLook[\let\next=\xxtms%
\else\let\next=\xxms\fi\next}
%
\def\xxtms[#1]#2{%
\mbox{%
\tabcolsep0pt\arraycolsep0pt%
$%
\left[%
\begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
#2%
\multicolumn{2}{>{\normalfont\itshape}l}{#1}%
\end{tabular}%
\right]%
$%
}%
\vspace{1mm}%
}

\def\xxms#1{%
\mbox{%
\tabcolsep0pt\arraycolsep0pt%
$%
\left[%
\begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
#1%
\end{tabular}%
\rule{0mm}{5mm}%
\right]%
$%
}%
\vspace{1mm}%
}



\def\onems{\tabcolsep0pt\arraycolsep0pt\futurelet\onemsLook\onemsdecide}
\def\onemsdecide{\ifx\onemsLook[\let\next=\xxtonems%
\else\let\next=\xxonems\fi\next}
%
\def\xxtonems[#1]#2{%
$\left[%
\begin{tabular}{>{\upshape\scshape}l}%
#2%
{\normalfont\itshape #1}% 
\end{tabular}% 
\right]$%
\vspace{1mm}%
}

\def\xxonems#1{%
\mbox{%
$%
\left[%
\begin{tabular}{>{\upshape\scshape}l}%
#1%
\end{tabular}%
\rule{0mm}{5mm}%
\right]%
$%
}%
\vspace{1mm}%
}

\makeatother

\begin{document}


\resizebox{\textwidth}{!}{%
  \begin{forest}
    [
      \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren ist Gerd Knecht nicht gefahren }\\
        synsem \onems{ l \onems{ cat|head|dt \sliste{ \ibox{1} [ l|cont|rels \ibox{2} ] }\\[1mm]
                                 cont|rels \ibox{8} $\oplus$ \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{
                                              arg & \ibox{5} \\
                            } } $\oplus$ \ibox{6} \\
                            }\\
                       is \ms{ topic & \sliste{ \ibox{1} }\\
                               focus & \sliste{ \sliste{ \ibox{3} } }\\
                             }\\
                     }\\
        c\_cont|hcons \liste{ \ms[qeq]{
                        harg & \ibox{5}\\
                        larg & \ibox{4}\\
                        } }\\
       }
      [ \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren }\\
        cat|head|dsl local \\
        cont|rels  \ibox{8}  \\
         } ]
      [   \onems{
        phon \phonliste{ ist Gerd Knecht nicht gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
                                 cont \ms{ ltop & \ibox{4}\\
                                           rels & \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{
                                                                                                           arg & \ibox{5} \\
                                                                                                          } } $\oplus$ \ibox{6}  \\
                                             }\\
        }
        [ \onems{
        phon \phonliste{ ist  }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels  \ibox{7}  \\
                               }
         ]
        [ \onems{
        phon \phonliste{ Gerd Knecht nicht gefahren }\\
        cont|rels   \ibox{2} $\oplus$ \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
         }
          [ \onems{
        phon \phonliste{ Gerd Knecht }\\
        synsem \ibox{1} [ l|cont|rels  \ibox{2} ] \\
          } ]
          [ \onems{
        phon \phonliste{ nicht gefahren }\\
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
                       is|focus \sliste{ \sliste{ \ibox{3} } }\\
            }
            [ \onems{
        phon \phonliste{ nicht  }\\
        cont|rels \liste{ \ibox{3} } \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
        } ]
            [ \onems{
        phon \phonliste{ gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6}\\
        } ] ] ] ] ]
\end{forest}}


\end{document}

由此得出下图:

在此处输入图片描述

编辑:添加

, for tree={calign=last}

对于 ist Gerd Knecht nicht gefahren-Node 来说,它提高了空间消耗,但是 AVM 却居中了:

在此处输入图片描述

答案1

垂直和水平对齐(更新的问题/评论中的问题)

在评论中,您询问如何将此处问题的答案与有关对齐节点顶部的问题的答案结合起来。

以下对齐节点:

  • 垂直:顶部
  • 水平:在右侧,除了第一级与前面一样对齐,在两个非幻影之间有一个幻影节点。

您也可以midpoint为根节点使用对齐选项,以避免使用幻像。但幻像比查找一次性对齐的正确选项更快。

这里的技巧是使用north east锚点对齐最右边的节点。但是,我们不想以这种方式绘制树,因为线条会位于错误的位置。

因此,在阶段设置节点的位置之后computing xy,我们会在绘制树的最后阶段之前改变子锚点和父锚点以将它们重置为默认值。

结果:

水平和垂直对齐

代码:

\documentclass{article}
\usepackage{forest}
\usepackage{array}
\makeatletter
\def\ibox#1{\mbox{}\setbox2=\hbox{$\scriptstyle #1$}\lower.2ex\vbox{\hrule
    \hbox{\vrule\kern1.25pt
      \vbox{\kern1.25pt\box2\kern1.25pt}\kern1.25pt\vrule}\hrule}}
\newcommand{\sliste}[1]{%
  \mbox{%
    $\left\langle\mbox{\upshape\scshape #1}\right\rangle$}%
}
\newcommand{\liste}[1]{%
  \mbox{%
    $%
    \left\langle\begin{tabular}{@{}>{\upshape\scshape}l@{}}#1\end{tabular}\right\rangle%
    $%
    %\\[-1.5mm]
  }%
}
\newcommand{\phonliste}[1]{%
  \mbox{%
    $%
    %
    \left\langle \mbox{\normalfont\itshape#1} \right\rangle%
    $%
    %\\[-1.5mm]
  }%
}
\setlength{\extrarowheight}{1pt}
\def\ms{\futurelet\msLook\msdecide}
\def\msdecide{\ifx\msLook[\let\next=\xxtms%
  \else\let\next=\xxms\fi\next}
%
\def\xxtms[#1]#2{%
  \mbox{%
    \tabcolsep0pt\arraycolsep0pt%
    $%
    \left[%
    \begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
      #2%
      \multicolumn{2}{>{\normalfont\itshape}l}{#1}%
    \end{tabular}%
    \right]%
    $%
  }%
  \vspace{1mm}%
}
\def\xxms#1{%
  \mbox{%
    \tabcolsep0pt\arraycolsep0pt%
    $%
    \left[%
    \begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
      #1%
    \end{tabular}%
    \rule{0mm}{5mm}%
    \right]%
    $%
  }%
  \vspace{1mm}%
}
\def\onems{\tabcolsep0pt\arraycolsep0pt\futurelet\onemsLook\onemsdecide}
\def\onemsdecide{\ifx\onemsLook[\let\next=\xxtonems%
  \else\let\next=\xxonems\fi\next}
%
\def\xxtonems[#1]#2{%
  $\left[%
  \begin{tabular}{>{\upshape\scshape}l}%
    #2%
    {\normalfont\itshape #1}%
  \end{tabular}%
  \right]$%
  \vspace{1mm}%
}
\def\xxonems#1{%
  \mbox{%
    $%
    \left[%
    \begin{tabular}{>{\upshape\scshape}l}%
      #1%
    \end{tabular}%
    \rule{0mm}{5mm}%
    \right]%
    $%
  }%
  \vspace{1mm}%
}
\makeatother

\begin{document}
  \resizebox{\textwidth}{!}{%
    \begin{forest}
      for tree={
        parent anchor=south,
        child anchor=north,
        anchor=north,
        align=center
      }
      [
      \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren ist Gerd Knecht nicht gefahren }\\
        synsem \onems{ l \onems{ cat|head|dt \sliste{ \ibox{1} [ l|cont|rels \ibox{2} ] }\\[1mm]
            cont|rels \ibox{8} $\oplus$ \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{
                arg & \ibox{5} \\
              } } $\oplus$ \ibox{6} \\
          }\\
          is \ms{ topic & \sliste{ \ibox{1} }\\
            focus & \sliste{ \sliste{ \ibox{3} } }\\
          }\\
        }\\
        c\_cont|hcons \liste{ \ms[qeq]{
            harg & \ibox{5}\\
            larg & \ibox{4}\\
          } }\\
      },
      [ \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren }\\
        cat|head|dsl local \\
        cont|rels  \ibox{8}  \\
      },
      ]
      [, phantom, calign with current]
      [   \onems{
        phon \phonliste{ ist Gerd Knecht nicht gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont \ms{ ltop & \ibox{4}\\
          rels & \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{
              arg & \ibox{5} \\
            } } $\oplus$ \ibox{6}  \\
        }\\
      },
      parent anchor=east,
      anchor=north east,
      for descendants={
        where n'=1{
          calign with current,
          anchor=north east,
        }{},
      },
      before drawing tree={
        parent anchor=south,
        for descendants={
          if n'=1{
            child anchor=north,
            parent anchor=south,
          }{}
        }
      }
      [ \onems{
        phon \phonliste{ ist  }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels  \ibox{7}  \\
      },
      ]
      [ \onems{
        phon \phonliste{ Gerd Knecht nicht gefahren }\\
        cont|rels   \ibox{2} $\oplus$ \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
      },
      [ \onems{
        phon \phonliste{ Gerd Knecht }\\
        synsem \ibox{1} [ l|cont|rels  \ibox{2} ] \\
      } ]
      [ \onems{
        phon \phonliste{ nicht gefahren }\\
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
      }
      [ \onems{
        phon \phonliste{ nicht  }\\
        cont|rels \liste{ \ibox{3} } \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
      } ]
      [ \onems{
        phon \phonliste{ gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6}\\
      } ] ] ] ] ]
    \end{forest}}
\end{document}

仅水平对齐(原始问题)

像这样?

对齐

\documentclass{article}
\usepackage{graphicx}
\usepackage{forest}
\forestset{.style={for tree={parent anchor=south, child anchor=north, align=center,base=top}}}
\usepackage{array}

\makeatletter

\def\ibox#1{\mbox{}\setbox2=\hbox{$\scriptstyle #1$}\lower.2ex\vbox{\hrule
    \hbox{\vrule\kern1.25pt
      \vbox{\kern1.25pt\box2\kern1.25pt}\kern1.25pt\vrule}\hrule}}
\newcommand{\sliste}[1]{%
  \mbox{%
    $\left\langle\mbox{\upshape\scshape #1}\right\rangle$}%
}
\newcommand{\liste}[1]{%
  \mbox{%
    $%
    \left\langle\begin{tabular}{@{}>{\upshape\scshape}l@{}}#1\end{tabular}\right\rangle%
    $%
    %\\[-1.5mm]
  }%
}
\newcommand{\phonliste}[1]{%
  \mbox{%
    $%
    %
    \left\langle \mbox{\normalfont\itshape#1} \right\rangle%
    $%
    %\\[-1.5mm]
  }%
}
\setlength{\extrarowheight}{1pt}
\def\ms{\futurelet\msLook\msdecide}
\def\msdecide{\ifx\msLook[\let\next=\xxtms%
  \else\let\next=\xxms\fi\next}
%
\def\xxtms[#1]#2{%
  \mbox{%
    \tabcolsep0pt\arraycolsep0pt%
    $%
    \left[%
    \begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
      #2%
      \multicolumn{2}{>{\normalfont\itshape}l}{#1}%
    \end{tabular}%
    \right]%
    $%
  }%
  \vspace{1mm}%
}
\def\xxms#1{%
  \mbox{%
    \tabcolsep0pt\arraycolsep0pt%
    $%
    \left[%
    \begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
      #1%
    \end{tabular}%
    \rule{0mm}{5mm}%
    \right]%
    $%
  }%
  \vspace{1mm}%
}
\def\onems{\tabcolsep0pt\arraycolsep0pt\futurelet\onemsLook\onemsdecide}
\def\onemsdecide{\ifx\onemsLook[\let\next=\xxtonems%
  \else\let\next=\xxonems\fi\next}
%
\def\xxtonems[#1]#2{%
  $\left[%
  \begin{tabular}{>{\upshape\scshape}l}%
    #2%
    {\normalfont\itshape #1}%
  \end{tabular}%
  \right]$%
  \vspace{1mm}%
}
\def\xxonems#1{%
  \mbox{%
    $%
    \left[%
    \begin{tabular}{>{\upshape\scshape}l}%
      #1%
    \end{tabular}%
    \rule{0mm}{5mm}%
    \right]%
    $%
  }%
  \vspace{1mm}%
}
\makeatother

\begin{document}
  \resizebox{\textwidth}{!}{%
    \begin{forest}
      [
      \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren ist Gerd Knecht nicht gefahren }\\
        synsem \onems{ l \onems{ cat|head|dt \sliste{ \ibox{1} [ l|cont|rels \ibox{2} ] }\\[1mm]
            cont|rels \ibox{8} $\oplus$ \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{
                arg & \ibox{5} \\
              } } $\oplus$ \ibox{6} \\
          }\\
          is \ms{ topic & \sliste{ \ibox{1} }\\
            focus & \sliste{ \sliste{ \ibox{3} } }\\
          }\\
        }\\
        c\_cont|hcons \liste{ \ms[qeq]{
            harg & \ibox{5}\\
            larg & \ibox{4}\\
          } }\\
      },
      [ \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren }\\
        cat|head|dsl local \\
        cont|rels  \ibox{8}  \\
      },
      ]
      [, phantom, calign with current]
      [   \onems{
        phon \phonliste{ ist Gerd Knecht nicht gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont \ms{ ltop & \ibox{4}\\
          rels & \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{
              arg & \ibox{5} \\
            } } $\oplus$ \ibox{6}  \\
        }\\
      },
      before typesetting nodes={
        parent anchor=east,
        anchor=east,
        for descendants={
            where n'=1{
              child anchor=east,
              calign with current,
              anchor=east,
            }{},
        }
      },
      [ \onems{
        phon \phonliste{ ist  }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels  \ibox{7}  \\
      },
      ]
      [ \onems{
        phon \phonliste{ Gerd Knecht nicht gefahren }\\
        cont|rels   \ibox{2} $\oplus$ \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
      },
      [ \onems{
        phon \phonliste{ Gerd Knecht }\\
        synsem \ibox{1} [ l|cont|rels  \ibox{2} ] \\
      } ]
      [ \onems{
        phon \phonliste{ nicht gefahren }\\
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
      }
      [ \onems{
        phon \phonliste{ nicht  }\\
        cont|rels \liste{ \ibox{3} } \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
      } ]
      [ \onems{
        phon \phonliste{ gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6}\\
      } ] ] ] ] ]
    \end{forest}}
\end{document}

或者像这样?

半对齐

\documentclass{article}
\usepackage{graphicx}
\usepackage{forest}
\forestset{.style={for tree={parent anchor=south, child anchor=north, align=center,base=top}}}
\usepackage{array}

\makeatletter

\def\ibox#1{\mbox{}\setbox2=\hbox{$\scriptstyle #1$}\lower.2ex\vbox{\hrule
    \hbox{\vrule\kern1.25pt
      \vbox{\kern1.25pt\box2\kern1.25pt}\kern1.25pt\vrule}\hrule}}
\newcommand{\sliste}[1]{%
  \mbox{%
    $\left\langle\mbox{\upshape\scshape #1}\right\rangle$}%
}
\newcommand{\liste}[1]{%
  \mbox{%
    $%
    \left\langle\begin{tabular}{@{}>{\upshape\scshape}l@{}}#1\end{tabular}\right\rangle%
    $%
    %\\[-1.5mm]
  }%
}
\newcommand{\phonliste}[1]{%
  \mbox{%
    $%
    %
    \left\langle \mbox{\normalfont\itshape#1} \right\rangle%
    $%
    %\\[-1.5mm]
  }%
}
\setlength{\extrarowheight}{1pt}
\def\ms{\futurelet\msLook\msdecide}
\def\msdecide{\ifx\msLook[\let\next=\xxtms%
  \else\let\next=\xxms\fi\next}
%
\def\xxtms[#1]#2{%
  \mbox{%
    \tabcolsep0pt\arraycolsep0pt%
    $%
    \left[%
    \begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
      #2%
      \multicolumn{2}{>{\normalfont\itshape}l}{#1}%
    \end{tabular}%
    \right]%
    $%
  }%
  \vspace{1mm}%
}
\def\xxms#1{%
  \mbox{%
    \tabcolsep0pt\arraycolsep0pt%
    $%
    \left[%
    \begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
      #1%
    \end{tabular}%
    \rule{0mm}{5mm}%
    \right]%
    $%
  }%
  \vspace{1mm}%
}
\def\onems{\tabcolsep0pt\arraycolsep0pt\futurelet\onemsLook\onemsdecide}
\def\onemsdecide{\ifx\onemsLook[\let\next=\xxtonems%
  \else\let\next=\xxonems\fi\next}
%
\def\xxtonems[#1]#2{%
  $\left[%
  \begin{tabular}{>{\upshape\scshape}l}%
    #2%
    {\normalfont\itshape #1}%
  \end{tabular}%
  \right]$%
  \vspace{1mm}%
}
\def\xxonems#1{%
  \mbox{%
    $%
    \left[%
    \begin{tabular}{>{\upshape\scshape}l}%
      #1%
    \end{tabular}%
    \rule{0mm}{5mm}%
    \right]%
    $%
  }%
  \vspace{1mm}%
}
\makeatother

\begin{document}
  \resizebox{\textwidth}{!}{%
    \begin{forest}
      [
      \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren ist Gerd Knecht nicht gefahren }\\
        synsem \onems{ l \onems{ cat|head|dt \sliste{ \ibox{1} [ l|cont|rels \ibox{2} ] }\\[1mm]
            cont|rels \ibox{8} $\oplus$ \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{
                arg & \ibox{5} \\
              } } $\oplus$ \ibox{6} \\
          }\\
          is \ms{ topic & \sliste{ \ibox{1} }\\
            focus & \sliste{ \sliste{ \ibox{3} } }\\
          }\\
        }\\
        c\_cont|hcons \liste{ \ms[qeq]{
            harg & \ibox{5}\\
            larg & \ibox{4}\\
          } }\\
      },
      [ \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren }\\
        cat|head|dsl local \\
        cont|rels  \ibox{8}  \\
      },
      ]
      [   \onems{
        phon \phonliste{ ist Gerd Knecht nicht gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont \ms{ ltop & \ibox{4}\\
          rels & \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{
              arg & \ibox{5} \\
            } } $\oplus$ \ibox{6}  \\
        }\\
      },
      [ \onems{
        phon \phonliste{ ist  }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels  \ibox{7}  \\
      },
      ]
      [ \onems{
        phon \phonliste{ Gerd Knecht nicht gefahren }\\
        cont|rels   \ibox{2} $\oplus$ \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
      },
      before typesetting nodes={
        parent anchor=east,
        anchor=east,
        for descendants={
            where n'=1{
              child anchor=east,
              calign with current,
              anchor=east,
            }{},
        }
      },
      [ \onems{
        phon \phonliste{ Gerd Knecht }\\
        synsem \ibox{1} [ l|cont|rels  \ibox{2} ] \\
      } ]
      [ \onems{
        phon \phonliste{ nicht gefahren }\\
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
      }
      [ \onems{
        phon \phonliste{ nicht  }\\
        cont|rels \liste{ \ibox{3} } \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
      } ]
      [ \onems{
        phon \phonliste{ gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6}\\
      } ] ] ] ] ]
    \end{forest}}
\end{document}

答案2

您必须将for tree={anchor=base east,calign=last}第二个女儿添加到第二个女儿(Gorn 地址 22)。这至少在某些情况下有效:

\documentclass{article}
\usepackage{graphicx}
\usepackage{forest}

\forestset{.style={for tree={parent anchor=south, child anchor=north,align=center,base=top}}}



\usepackage{array}


\makeatletter

\def\ibox#1{\mbox{}\setbox2=\hbox{$\scriptstyle #1$}\lower.2ex\vbox{\hrule
        \hbox{\vrule\kern1.25pt 
        \vbox{\kern1.25pt\box2\kern1.25pt}\kern1.25pt\vrule}\hrule}}


\newcommand{\sliste}[1]{%
\mbox{%
$\left\langle\mbox{\upshape\scshape #1}\right\rangle$}%
}

\newcommand{\liste}[1]{%
\mbox{%
$%
\left\langle\begin{tabular}{@{}>{\upshape\scshape}l@{}}#1\end{tabular}\right\rangle%
$%
%\\[-1.5mm]
}%
}


\newcommand{\phonliste}[1]{%
\mbox{%
$%
%
\left\langle \mbox{\normalfont\itshape#1} \right\rangle%
$%
%\\[-1.5mm]
}%
}


\setlength{\extrarowheight}{1pt}

\def\ms{\futurelet\msLook\msdecide}
\def\msdecide{\ifx\msLook[\let\next=\xxtms%
\else\let\next=\xxms\fi\next}
%
\def\xxtms[#1]#2{%
\mbox{%
\tabcolsep0pt\arraycolsep0pt%
$%
\left[%
\begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
#2%
\multicolumn{2}{>{\normalfont\itshape}l}{#1}%
\end{tabular}%
\right]%
$%
}%
\vspace{1mm}%
}

\def\xxms#1{%
\mbox{%
\tabcolsep0pt\arraycolsep0pt%
$%
\left[%
\begin{tabular}{>{\upshape\scshape}l@{\hspace{5pt}}>{\normalfont\itshape}l}%
#1%
\end{tabular}%
\rule{0mm}{5mm}%
\right]%
$%
}%
\vspace{1mm}%
}



\def\onems{\tabcolsep0pt\arraycolsep0pt\futurelet\onemsLook\onemsdecide}
\def\onemsdecide{\ifx\onemsLook[\let\next=\xxtonems%
\else\let\next=\xxonems\fi\next}
%
\def\xxtonems[#1]#2{%
$\left[%
\begin{tabular}{>{\upshape\scshape}l}%
#2%
{\normalfont\itshape #1}% 
\end{tabular}% 
\right]$%
\vspace{1mm}%
}

\def\xxonems#1{%
\mbox{%
$%
\left[%
\begin{tabular}{>{\upshape\scshape}l}%
#1%
\end{tabular}%
\rule{0mm}{5mm}%
\right]%
$%
}%
\vspace{1mm}%
}

\makeatother

\begin{document}


\resizebox{\textwidth}{!}{%
  \begin{forest}
    [
      \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren ist Gerd Knecht nicht gefahren }\\
        synsem \onems{ l \onems{ cat|head|dt \sliste{ \ibox{1} [ l|cont|rels \ibox{2} ] }\\[1mm]
                                 cont|rels \ibox{8} $\oplus$ \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{
                                              arg & \ibox{5} \\
                            } } $\oplus$ \ibox{6} \\
                            }\\
                       is \ms{ topic & \sliste{ \ibox{1} }\\
                               focus & \sliste{ \sliste{ \ibox{3} } }\\
                             }\\
                     }\\
        c\_cont|hcons \liste{ \ms[qeq]{
                        harg & \ibox{5}\\
                        larg & \ibox{4}\\
                        } }\\
       }
      [ \onems{
        phon \phonliste{ nach Brüssel zum Demonstrieren }\\
        cat|head|dsl local \\
        cont|rels  \ibox{8}  \\
         } ]
      [   \onems{
        phon \phonliste{ ist Gerd Knecht nicht gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
                                 cont \ms{ ltop & \ibox{4}\\
                                           rels & \ibox{7} $\oplus$ \ibox{2} $\oplus$ \liste{ \ibox{3} \ms[nicht-rel]{                                                             } } $\oplus$ \ibox{6}  \\
                                             }\\
        }
        [ \onems{
        phon \phonliste{ ist  }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels  \ibox{7}  \\
                               }
         ]
        [ \onems{
        phon \phonliste{ Gerd Knecht nicht gefahren }\\
        cont|rels   \ibox{2} $\oplus$ \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
         },for tree={anchor=base east,calign=last}
          [ \onems{
        phon \phonliste{ Gerd Knecht }\\
        synsem \ibox{1} [ l|cont|rels  \ibox{2} ] \\
          } ]
          [ \onems{
        phon \phonliste{ nicht gefahren }\\
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6} \\
                       is|focus \sliste{ \sliste{ \ibox{3} } }\\
            }
            [ \onems{
        phon \phonliste{ nicht  }\\
        cont|rels \liste{ \ibox{3} } \\
        is|focus \sliste{ \sliste{ \ibox{3} } }\\
        } ]
            [ \onems{
        phon \phonliste{ gefahren }\\
        cat|head|dt \sliste{ \ibox{1} }\\[1mm]
        cont|rels \liste{ \ibox{3} } $\oplus$ \ibox{6}\\
        } ] ] ] ] ]
\end{forest}}


\end{document}

在此处输入图片描述

相关内容