8

I would like to have forest trees that allow a very limited kind of multidominance, as shown in the picture below:

multidominant tree

The basic idea is that the terminal node a is centred between and dominated by both X nodes.

This was produced in the following hacky way: I made a ternary branching tree with a phantom middle edge so that the terminal was the terminal node of the middle branch and then manually drew multidominant the branches. This works fine, but I'm wondering if there is a less hacky way to do it.

\documentclass{article}
\usepackage[linguistics]{forest}
\forestset{multi/.style={before typesetting nodes={
     prepend={[X,name=X1,tier=x]},
     append={[X,name=X2,tier=x]}}}}
\begin{document}
\begin{forest}
    [A,s sep=0pt,multi
        [X,phantom, tier=x [a,tier=s,name=X ]]
    ]
\draw (X1.south) -- (X.north);
\draw (X2.south) -- (X.north);
\end{forest} 
\end{document}
Alan Munn
  • 218,180

1 Answers1

7
\documentclass[border=9pt]{standalone}
\usepackage[linguistics]{forest}
\forestset{
  declare toks={multi name}{},
  multi dom/.style={
    if={>On={level}{0}}{}{%
      delay/.process={OOw2}{name}{multi name}{
        insert before={[##2,tier=##1]},
        insert after={[##2,tier=##1]},
        !u.s sep'=0pt,
      },
      before typesetting nodes={
        replace by/.process={OOw2}{name}{multi name}{[##2, phantom, before drawing tree={content=, no edge, phantom=0, typeset node}, tier=##1, delay={append=##1}]}
      },
      edge path'={(!up.parent anchor) -- (.child anchor) -- (!un.parent anchor)},
    },
  },
  multi/.style={
    multi name=#1,
    multi dom,
  },
}
\begin{document}
\begin{forest}
  [A
    [a,multi=X ]
  ]
\end{forest} 
\begin{forest}
  [A
    [a,multi=X ]
    [b [c,multi=C] ]
    [f [g,multi=H] ]
  ]
\end{forest} 
\begin{forest}
  for tree={multi name=J}
  [A
    [a,multi dom ]
    [b [c,multi=C] ]
    [f [g,multi dom] ]
  ]
\end{forest} 
\begin{forest}
  [C [A
      [a, multi=C  ]
  ]
    [B [c,multi=V ]]
  ]
\end{forest}
\end{document}

too many oppressed children being dominated by parents

cfr
  • 198,882