TransWikia.com

Coloring all nodes that follow to a specific terminal node

TeX - LaTeX Asked by Utku Türk on October 13, 2020

I have been trying to color some nodes with filled dots. But I am stuck, following the forest package guideline, I was only able to fill only first and two rows.

What I am trying to do:

whatI want to do

I was only able to do first and second one. Here’s my minimal code:

documentclass[border=3mm]{standalone}
usepackage[linguistics,edges]{forest} 
forestset{
ned/.style={%
    for tree={calign=fixed edge angles},
    delay={%
      where content={}{%
        shape=coordinate,
        for nodewalk={%
          Nodewalk={%
            on invalid=fake,
          }{%
            parent,
          }{%
            for children={anchor=north},
          }
        }{},
      }{},
    },
},
}

begin{document}

begin{forest}
ned
[DP
  [
    [
      [pro]
      [
        [VP
          [NP ttextsubscript{1}]
          [VTuttukları]
        ]
        [T]
      ]
    ]
    [C]
  ]
  [
    [NPaşçı]
    [D]
  ]
]
path[fill=red] (.parent anchor) circle[radius=2pt];
path[fill=red] (!1.child anchor) circle[radius=2pt];
end{forest}

end{document}

One Answer

To make it easier to understand I chose one color per node (you can change them to red according to your needs).

From top to bottom:

path[fill=red] (.parent anchor) circle[radius=2pt];
path[fill=black] (!1.child anchor) circle[radius=2pt];
path[fill=green] (!11.child anchor) circle[radius=2pt];
path[fill=blue] (!112.child anchor) circle[radius=2pt];
path[fill=yellow] (!1121.south) circle[radius=2pt];
path[fill=orange] (!11212.child anchor) circle[radius=2pt];

enter image description here

MWE:

documentclass[border=3mm]{standalone}
usepackage[linguistics,edges]{forest} 
forestset{
ned/.style={%
    for tree={calign=fixed edge angles},
    delay={%
      where content={}{%
        shape=coordinate,
        for nodewalk={%
          Nodewalk={%
            on invalid=fake,
          }{%
            parent,
          }{%
            for children={anchor=north},
          }
        }{},
      }{},
    },
},
}

begin{document}

begin{forest}
ned
[DP
  [
    [
      [pro]
      [
        [VP
          [NP ttextsubscript{1}]
          [VTuttukları]
        ]
        [T]
      ]
    ]
    [C]
  ]
  [
    [NPaşçı]
    [D]
  ]
]
path[fill=red] (.parent anchor) circle[radius=2pt];
path[fill=black] (!1.child anchor) circle[radius=2pt];
path[fill=green] (!11.child anchor) circle[radius=2pt];
path[fill=blue] (!112.child anchor) circle[radius=2pt];
path[fill=yellow] (!1121.south) circle[radius=2pt];
path[fill=orange] (!11212.child anchor) circle[radius=2pt];
end{forest}

end{document}

I think it is self-explanatory, otherwise let me know.

Correct answer by Ñako on October 13, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP