Any chance I can render multiple ToC within a notebook for a dynamic composite ToC?
edit Apologies for being too terse:
I have several notebooks with Tables of Contents. Each independently works in the context of the notebook. Each can also be embedded–but only when I embed the entire notebook (I just discovered this):
… What I was trying to do was to embed the rendered ToC into another notebook, which is effectively a massive outline of may several independent chapters. Seeing now, however, that the individual rendered toc() cells are not embedding, I suspect that there will be no “easy solution” to this issue. I also see here that trying to embed both ToC are causing interference. … Alas!
That helper parses the current page to build the toc.
Technically it’s not possible to determine the tree of contents until you’ve rendered the entire notebook, with every cell in it. If this were a “proper” TOC with static links, you could then inspect and copy its HTML and paste it into your notebook. Alas, that’s not going to work in this case, because
there are no anchors to point the links to, and
even if there were, they wouldn’t work, because you can only link to cells (via the cell menu’s “Copy link” option).
As tedious as it might be: My recommendation would be to construct your TOC manually, and have the links point to the individual cells. If you name your TOC cell, you can then also import it into other notebooks.
I have effectively been following the approach you outline (though not the the extent of creating anchor links). I was hoping to automate as some of my team members are complaining about content getting outdated as they work. Thank you for clarifying why this approach failed
@aaronkyle Thank you for the kind words! Are you OK with me using one of your notebooks as the default example? Happy to change it to something else if you’d prefer that.