在 TikZ Forest 节点下添加多层括号

在 TikZ Forest 节点下添加多层括号

我想通过在语言家族树的某些子部分下方添加括​​号来对其进行注释。灵感来自另一个问题,我目前已经

\begin{forest}
  for tree={s sep=2mm, inner sep=0, l=4mm},
  for leaves={anchor=west, rotate=-90, tier=attestedlangs},
  delay={for tree={name/.pgfmath=content}},
  forked edges,
  [TAP
    [AP,
      for relative level=1{edge=double},
        [Pantar
          [Western Pantar]
          [Teiwa]
          [Klamu]
        ]
        [Kaera]
        [Straits, tier=dial
          [Blagar]
          [Reta]
        ]
      [W Alor, tier=lang
        [, tier=dial
          [Hamap]
          [Adang-Otvai]
        ]
        [, tier=dial
          [Adang-Lawahing]
          [Kabola]
        ]
      ]
      [Klon]
      [Kafoa]
      [Nuclear Alor
        [, tier=lang
          [Kui]
          [Kiraman]
        ]
        [
          [Abui]
          [
            [Kamang]
            [, tier=lang
              [, tier=dial
                [Kula]
                [Sawila]
              ]
              [Wersing]
            ]
          ]
        ]
      ]
    ]
    [E Timor, tier=lang
      [Makasae]
      [
        [Fataluku, name=Fataluku]
        [Oirata, name=Oirata]
      ]
    ]
    [Bunak]
  ]
  \draw[decorate,decoration={brace,amplitude=1em,mirror}] (Kaera.south east) -- node[below=1em] {*q > k} (Wersing.north east);
  \draw[decorate,decoration={brace,amplitude=1em,mirror}] (Blagar.south east) -- node[below=1em] {*s > h} (Kafoa.north east);

\end{forest}

这会产生下面两个图的顶部,我想实现底部的一个。

两种树形结构。当前输出结果位于顶部,期望输出位于底部。

作为一种解决方法,我只需尝试在树中添加更多层并连接它们,例如

[Blagar, rotate=-90, anchor=west, name=Blagar, tier=attestedlangs
 [,name=Blagar1, tier=below1, edge=none 
  [,name=Blagar2, tier=below2, edge=none]]]

然后连接(Blagar2.south west)而不是(Blagar.south east),但这似乎是手动构建此结构的一种极其麻烦的方法,而且我不知道如何使用for leavesdelay类似的 Forest 自动化结构来构建它。

答案1

您可以使用current bounding box更新的节点以及|-语法来执行

  \path (current bounding box.south) coordinate (s1);
  \draw[decorate,decoration={brace,amplitude=1em,mirror}] 
    (Kaera.south east|-s1) -- node[below=1em] {*q $>$ k} (Wersing.north east|-s1);
  \path (current bounding box.south) coordinate (s2);
  \draw[decorate,decoration={brace,amplitude=1em,mirror}] 
  (Blagar.south east|-s2) -- node[below=1em] {*s $>$ h} (Kafoa.north east|-s2);

完整 MWE:

\documentclass[tikz,border=3mm]{standalone}
\usepackage[edges]{forest}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{forest}
  for tree={s sep=2mm, inner sep=0, l=4mm},
  for leaves={anchor=west, rotate=-90, tier=attestedlangs},
  delay={for tree={name/.pgfmath=content}},
  forked edges,
  [TAP
    [AP,
      for relative level=1{edge=double},
        [Pantar
          [Western Pantar]
          [Teiwa]
          [Klamu]
        ]
        [Kaera]
        [Straits, tier=dial
          [Blagar]
          [Reta]
        ]
      [W Alor, tier=lang
        [, tier=dial
          [Hamap]
          [Adang-Otvai]
        ]
        [, tier=dial
          [Adang-Lawahing]
          [Kabola]
        ]
      ]
      [Klon]
      [Kafoa]
      [Nuclear Alor
        [, tier=lang
          [Kui]
          [Kiraman]
        ]
        [
          [Abui]
          [
            [Kamang]
            [, tier=lang
              [, tier=dial
                [Kula]
                [Sawila]
              ]
              [Wersing]
            ]
          ]
        ]
      ]
    ]
    [E Timor, tier=lang
      [Makasae]
      [
        [Fataluku, name=Fataluku]
        [Oirata, name=Oirata]
      ]
    ]
    [Bunak]
  ]
  \path (current bounding box.south) coordinate (s1);
  \draw[decorate,decoration={brace,amplitude=1em,mirror}] 
    (Kaera.south east|-s1) -- node[below=1em] {*q $>$ k} (Wersing.north east|-s1);
  \path (current bounding box.south) coordinate (s2);
  \draw[decorate,decoration={brace,amplitude=1em,mirror}] 
  (Blagar.south east|-s2) -- node[below=1em] {*s $>$ h} (Kafoa.north east|-s2);
\end{forest}
\end{document}

在此处输入图片描述

相关内容