TransWikia.com

Vertical dots in a tree with forest

TeX - LaTeX Asked on December 1, 2021

I am writing a paper about the collatz conjecture, and I want to show a diagram, but I don’t know how to add ellipses to the tree.

usepackage{forest}

begin{forest} for tree={
    edge path={noexpandpath[forestoption{edge}] (forestOve{forestove{@parent}}{name}.parent anchor) -- +(0,-12pt)-| (forestove{name}.child anchor)forestoption{edge label};}
}

[1
    [2
        [4
            [8
                [16
                    [32
                        [64
                            [128
                                [256]
                            ]
                            [21
                                [42]
                            ]
                        ]
                    ]
                    [5
                        [10
                            [20
                                [40]
                            ]
                            [3
                                [6]
                            ]
                        ]
                    ]
                ]
            ]
        ]
    ]
]

end{forest}

I want the ellipses to be where the red rectangles are, if possible

One Answer

The simplest solution is just to add them to the terminal nodes directly. By using align=center you can use linebreaks inside nodes. I've also made all content math, which simplifies the code slightly.

I've removed your path code which gave errors and doesn't seem to do much.

documentclass{article}
usepackage{forest}
begin{document}
begin{forest}
for tree={math content,align=center}
[1
    [2
        [4
            [8
                [16
                    [32
                        [64
                            [128
                                [256\vdots]
                            ]
                            [21
                                [42\vdots]
                            ]
                        ]
                    ]
                    [5
                        [10
                            [20
                                [40\vdots]
                            ]
                            [3
                                [6\vdots]
                            ]
                        ]
                    ]
                ]
            ]
        ]
    ]
]
end{forest}

end{document}

output of code

Answered by Alan Munn on December 1, 2021

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