[NTG-context] Custom Table of Contents

andrei at borisov.dev andrei at borisov.dev
Thu Jan 20 15:45:38 CET 2022

Hi! I’m new to ConTeXt.

I need to make a custom table of contents that looks like this:


Each row in the table corresponds to an item that has following data to print in the table of contents: page, total number of pages which the item spans, name of the item and a custom text metadata field which is defined by the item. Each item will have its own regular table of content and own structure. So we can think of this TOC as kind of a mega table of content one level above.

It needs to be fully automatic.
The actual table is going to be an xtable (which I was blown away by after using LaTeX godawful tables for years, it’s soo good).

After digging into the documentation (again, wow, it’s soo detailed and approachable after LaTeX😂), I found out that \completecontent doesn't provide such extreme level of customization. Therefore I need reimplement at least some parts of the default content forming mechanism. After digging in the source a bit, I found something relevant: https://source.contextgarden.net/tex/context/base/mkxl/strc-lst.mklx <https://source.contextgarden.net/tex/context/base/mkxl/strc-lst.mklx>.

What I need is some guidance on what would be the best course of action, in particular, which API should I use and roughly how should I approach it🙏

Should I create my own counters for each item and somehow reference those manually in the TOC?

How would I save additional text metadata field and the item name to show it in the TOC?

The source code mentions a concept of list renderers. This sounds like the correct API to plug in, but it’s hard for me to grasp how exactly it works.

Any help will be appreciated! Thank you in advance!

Stay safe,
Andrei Borisov.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20220120/8c6bc670/attachment-0001.htm>

More information about the ntg-context mailing list