On 1/20/2022 3:45 PM, andrei--- via ntg-context wrote: > Hi! I’m new to ConTeXt. > > I need to make a custom table of contents that looks like this: > > https://imgur.com/a/Ca3By6X > > 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 anxtable(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\completecontentdoesn'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 > . there are some examples in the test suite ... if you look into the stc-lst files you'll see that one has access to fields and can use setups > 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. The problem with tables is that they are multipass and store (unexpanded) data so it has not enough info. Attached is an example of how to circumvent this (the helpers can be found in the lua file). (You can then try to add it to the wiki so that it gets documented. The lua-context interface wrt TABLE can do the same from the lua end as in tex. There are examples of that.) Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------