7

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}
  • +1 Isn't that what @cfr's "not a tree" does? – user121799 Sep 15 '18 at 18:19
  • @marmot Yes perhaps. This is one of those cases where 'less hacky' ≠ 'easy to understand'. – Alan Munn Sep 15 '18 at 18:22
  • 3
    @marmot In that code I can't see the tree in the forest. :) – Alan Munn Sep 15 '18 at 18:25
  • I do advise against using Forest. – cfr Oct 5 at 23:11
  • @cfr If you're around could talk about this in the chat? – Alan Munn Oct 6 at 0:04
6
+250
\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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.