编辑

编辑

我想要绘制下图:

在此处输入图片描述

我现在将我的树转换为forest以下代码:

\documentclass{article}

\usepackage{forest}



\forestset{
sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=top},
                 where n children=0{tier=word}{}
                 },
% auxiliary nodes without node label
empty nodes/.style={
  delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}}
}


\begin{document}

\begin{figure}[htbp]
\centerline{%
\begin{tabular}{@{}l@{}}
\begin{forest}
sn edges,empty nodes
[CP
[{} [XP]]
  [C$'$ [{} [C$^0$]]
        [IP [{} [XP]]
            [I$'$
              [VP
                [V$^0$]]
              [{} [I$^0$]]]]]]
\end{forest}\\
\begin{tabular}{|l|l|l|l|l|}
\hline
%
SpecCP   & C0      & \multicolumn{2}{l|}{IP (without I0, V0)} & V0, I0\\
prefield & left SB     & \multicolumn{2}{l|}{middlefield}                 & right SB\\\cline{3-4}
         &             & SpecIP           & phrases inside       &          \\
         &             & subject position & the VP               &\\\hline
\end{tabular}
\end{tabular}}
\caption{\label{Abb-GB-Topo}CP, IP and VP and the topological model of German}
\end{figure}



\end{document}

此代码生成:

在此处输入图片描述

第一个图形是用 pstricks 或多或少手工完成的,我想知道是否有更好的方法来确保 XP 位于单元格 SpecCP 和 SpecIP 上方的中间,并且三角形即将在单元格处结束Phrasen innerhalb der VP

编辑:

根据 cfr 的建议,我开始使用以下代码:

\documentclass{article}
\usepackage{forest}
\forestset{
  sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=top}},
  terminus/.style={tier=word, for tree={fit=band}, for descendants={no path, align=left, l sep=0pt}},
  empty nodes/.style={
    delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}},
  no path/.style={edge path={}},
  set me left/.style={calign with current edge, child anchor=north west, for parent={parent anchor=south west}},
}

\begin{document}

\begin{figure}[htbp]
\centering
\begin{forest}
    sn edges,empty nodes
    [CP
      [{}
        [XP,terminus
          [SpecCP\\prefield, name=prefield
          ]
        ]
      ]
      [C$'$
            [{}
              [C$^0$, terminus
                [C0\\left SB
                ]
              ]
            ]
            [IP
              [{}
                [XP, terminus
                  [{IP (without I0, V0)\\middlefield}, name=middlefield
                    [SpecIP\\subject position, set me left, name=subject
                    ]
                    [phrases inside\\the VP, name=insidevp
                    ]
                  ]
                ]
              ]
              [I$'$
                      [VP, name=vp
                        [V$^0$, name=v0, terminus, no path
                          [{V0, I0\\right SB}, name=p2
                          ]
                        ]
                      ]
                      [{}
                            [I$^0$, terminus
                            ]
                      ]
              ]
            ]
      ]
    ]
    % these are the table borders at the top and at the bottom
    \draw [thick]
      (prefield.north west) -- (p2.north east)
      (prefield.west |- insidevp.south) -- (p2.east |- insidevp.south);
    \draw
      % the horizontal line in the middle 
      % for reasons I do not understand, the middlefield node does not extend over the `phrases
      % inside VP' node.
      %(middlefield.south west) -- (middlefield.south east)
      (subject.north west) -- (insidevp.north east)
      (vp.south) -- (v0.center -| insidevp.west) -- (v0.west)
      (v0.east) -- +(2.5pt,0) -- (vp.south)
      ;
\end{forest}
\caption{\label{Abb-GB-Topo}CP, IP and VP and the topological model of German}
\end{figure}

\end{document}

我用更能说明问题的节点名替换了 p1-p3,middlefield并画了一条更短的线来标记中场区域。我尝试这样做,(middlefield.south west) -- (middlefield.south east)但不知何故这不起作用。虽然中场节点主导了 SpecIP 的节点和 VP 内的短语,但这条线太短了。

还有一个问题:V0 和 I0 是右句子括号的一部分,也就是说,这两个节点应该主导 V0 和 I0 的解释节点。我认为实现这一点的最简单方法可能是将右 SB 的节点向右移动,使其位于 I0 下方。但也许有更好的方法。

在此处输入图片描述

至于垂直线,我必须在预场、左 SB 和右 SB 下方引入假节点,并将它们的右南角连接到上方节点的右北角,不是吗?

以下是我尝试过的,但是中场节点太短,并且第二条垂直线不在左 SB 和中场节点的中间,而是更靠近中场节点,因为我参考了后者节点的坐标。

\documentclass{article}
\usepackage{forest}
\forestset{
  sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=top}},
  terminus/.style={tier=word, for tree={fit=band}, for descendants={no path, align=left, l sep=0pt}},
  empty nodes/.style={
    delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}},
  no path/.style={edge path={}},
  set me left/.style={calign with current edge, child anchor=north west, for parent={parent anchor=south west}},
}

\begin{document}

\begin{figure}[htbp]
\centering
\begin{forest}
    sn edges,empty nodes
    [CP
      [{}
        [XP,terminus
          [SpecCP\\prefield, name=prefield
          ]
        ]
      ]
      [C$'$
            [{}
              [C$^0$, terminus
                [C0\\left SB,name=leftSB
                ]
              ]
            ]
            [IP
              [{}
                [XP, terminus
                  [{IP (without I0, V0)\\middlefield}, name=middlefield
                    [SpecIP\\subject position, set me left, name=subject
                    ]
                    [phrases inside\\the VP, name=insidevp
                    ]
                  ]
                ]
              ]
              [I$'$
                      [VP, name=vp
                        [V$^0$, name=v0, terminus, no path
                          [{V0, I0\\right SB}, name=rightSB
                          ]
                        ]
                      ]
                      [{}
                            [I$^0$, terminus
                            ]
                      ]
              ]
            ]
      ]
    ]
    % these are the table borders at the top and at the bottom
    \draw [thick]
      (prefield.north west) -- (rightSB.north east)
      (prefield.west |- insidevp.south) -- (rightSB.east |- insidevp.south);
    \draw
      % the horizontal line in the middle 
      % for reasons I do not understand, the middlefield node does not extend over the `phrases
      % inside VP' node.
      %(middlefield.south west) -- (middlefield.south east)
      (subject.north west) -- (insidevp.north east)
      %vertical lines
      (prefield.north east) -- (prefield.south east)
      (middlefield.north west)   -- (subject.south west)
      (middlefield.north east)   -- (insidevp.south east)
      %
      (vp.south) -- (v0.center -| insidevp.west) -- (v0.west)
      (v0.east) -- +(2.5pt,0) -- (vp.south)
      ;
\end{forest}
\caption{\label{Abb-GB-Topo}CP, IP and VP and the topological model of German}
\end{figure}

\end{document}

在此处输入图片描述

答案1

这实现了 ajeh 在评论中提出的建议。

编辑

这是一个添加了垂直规则的版本,我最初省略了这些规则(见下文),因为在这种情况下显然需要这些规则。

\documentclass{article}
\usepackage{forest}
\forestset{
  sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=top}},
  terminus/.style={tier=word, for children={tier=tabular}, for tree={fit=band}, for descendants={no path, align=left, l sep=0pt}},
  empty nodes/.style={
    delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}},
  no path/.style={edge path={}},
  set me left/.style={calign with current edge, child anchor=north west, for parent={parent anchor=south west}},
}
\usetikzlibrary{calc}
\begin{document}

  \begin{figure}[htbp]
    \centering
    \begin{forest}
        sn edges,empty nodes
        [CP
          [{}
            [XP,terminus
              [SpecCP\\prefield, name=p1
              ]
            ]
          ]
          [C$'$
                [{}
                  [C$^0$, terminus
                    [C0\\left SB, name=c0
                    ]
                  ]
                ]
                [IP
                  [{}
                    [XP, terminus
                      [{IP (without I0, V0)\\middlefield}
                        [SpecIP\\subject position, set me left, name=specip
                        ]
                        [phrases inside\\the VP, name=p3
                        ]
                      ]
                    ]
                  ]
                  [I$'$
                          [VP, name=vp
                            [V$^0$, name=v0, terminus, no path, anchor=east
                              [{V0, I0\\right SB}, name=p2, set me left
                              ]
                            ]
                          ]
                          [{}
                                [I$^0$, terminus, name=io
                                ]
                          ]
                  ]
                ]
          ]
        ]
        \draw [thick]
          (p1.north west) rectangle (io.east |- p3.south);
        \draw
          ($(c0.north east)!1/2!(specip.west |- c0.north east)$) coordinate (p6) -- (p6 |- p3.south)
          ($(p1.north east)!1/2!(c0.north west)$) coordinate (p4) -- (p3.south -| p4)
          ($(specip.north east)!1/2!(p3.north west)$) coordinate (p5) -- (p3.south -| p5)
          ($(p2.north west)!1/2!(p2.north west -| p3.east)$) coordinate (p7) -- (p3.south -| p7)
          (p6 |- p2.south) -- (p2.south -| p7)
          (vp.south) -- (v0.center -| p3.west) -- (v0.west)
          (v0.east) -- +(2.5pt,0) -- (vp.south)
          ;
    \end{forest}
    \caption{\label{Abb-GB-Topo}CP, IP and VP and the topological model of German}
\end{figure}

\end{document}

具有垂直规则的森林表格

calc用于计算两点之间的中点。例如,是和($(a)!1/2!(b)$)之间的中点。表示与垂直对齐和水平对齐的点。实际使用的计算只是这两个想法的组合,并结合使用来命名树中的各个节点。(a)(b)(a |- b)(a)(b)name=

初步解决方案

由于在表格中包含垂直规则在印刷上是令人厌恶的,所以我最初省略了这些。由于在其他规则本身没有意义的情况下,它可能对其他人有用,所以这里是原始解决方案。[如果您希望booktabs更精确地遵循建议,您可以调整规则宽度;)。]

\documentclass{article}
\usepackage{forest}
\forestset{
  sn edges/.style={for tree={parent anchor=south, child anchor=north,align=center,base=top}},
  terminus/.style={tier=word, for tree={fit=band}, for descendants={no path, align=left, l sep=0pt}},
  empty nodes/.style={
    delay={where content={}{shape=coordinate,for parent={for children={anchor=north}}}{}}},
  no path/.style={edge path={}},
  set me left/.style={calign with current edge, child anchor=north west, for parent={parent anchor=south west}},
}

\begin{document}

  \begin{figure}[htbp]
    \centering
    \begin{forest}
        sn edges,empty nodes
        [CP
          [{}
            [XP,terminus
              [SpecCP\\prefield, name=p1
              ]
            ]
          ]
          [C$'$
                [{}
                  [C$^0$, terminus
                    [C0\\left SB
                    ]
                  ]
                ]
                [IP
                  [{}
                    [XP, terminus
                      [{IP (without I0, V0)\\middlefield}
                        [SpecIP\\subject position, set me left
                        ]
                        [phrases inside\\the VP, name=p3
                        ]
                      ]
                    ]
                  ]
                  [I$'$
                          [VP, name=vp
                            [V$^0$, name=v0, terminus, no path
                              [{V0, I0\\right SB}, name=p2
                              ]
                            ]
                          ]
                          [{}
                                [I$^0$, terminus
                                ]
                          ]
                  ]
                ]
          ]
        ]
        \draw [thick]
          (p1.north west) -- (p2.north east)
          (p1.west |- p3.south) -- (p2.east |- p3.south);
        \draw
          (p1.south west) -- (p2.south east)
          (vp.south) -- (v0.center -| p3.west) -- (v0.west)
          (v0.east) -- +(2.5pt,0) -- (vp.south)
          ;
    \end{forest}
    \caption{\label{Abb-GB-Topo}CP, IP and VP and the topological model of German}
\end{figure}

\end{document}

森林树中的假表格

相关内容