From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.comp.tex.context/114225 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Hans Hagen via ntg-context Newsgroups: gmane.comp.tex.context Subject: Re: Custom Table of Contents Date: Thu, 20 Jan 2022 17:39:16 +0100 Message-ID: <874f4b12-b7ea-0928-417a-f03ffdcc978d@xs4all.nl> References: <36EDA4FC-F41E-43A6-8379-9AE4D53FDDA6@borisov.dev> Reply-To: mailing list for ConTeXt users Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------NFbFWqUpNH7kmm9oF9V7QiCN" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="33789"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Cc: Hans Hagen To: mailing list for ConTeXt users Original-X-From: ntg-context-bounces@ntg.nl Thu Jan 20 17:40:10 2022 Return-path: Envelope-to: gctc-ntg-context-518@m.gmane-mx.org Original-Received: from zapf.boekplan.nl ([5.39.185.232] helo=zapf.ntg.nl) by ciao.gmane.io with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAaTq-0008aN-05 for gctc-ntg-context-518@m.gmane-mx.org; Thu, 20 Jan 2022 17:40:10 +0100 Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 2DA5D287C69; Thu, 20 Jan 2022 17:39:24 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LvoeyoLoFeHM; Thu, 20 Jan 2022 17:39:22 +0100 (CET) Original-Received: from zapf.ntg.nl (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 5EB28283029; Thu, 20 Jan 2022 17:39:22 +0100 (CET) Original-Received: from localhost (localhost [127.0.0.1]) by zapf.ntg.nl (Postfix) with ESMTP id 7ECF6283029 for ; Thu, 20 Jan 2022 17:39:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at zapf.boekplan.nl Original-Received: from zapf.ntg.nl ([127.0.0.1]) by localhost (zapf.ntg.nl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id vuOGCyWN6saj for ; Thu, 20 Jan 2022 17:39:18 +0100 (CET) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=195.121.94.169; helo=ewsoutbound.kpnmail.nl; envelope-from=j.hagen@xs4all.nl; receiver= Original-Received: from ewsoutbound.kpnmail.nl (ewsoutbound.kpnmail.nl [195.121.94.169]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by zapf.ntg.nl (Postfix) with ESMTPS id 815EB282AD7 for ; Thu, 20 Jan 2022 17:39:18 +0100 (CET) X-KPN-MessageId: 803bdef9-7a0f-11ec-bb40-005056abad63 Original-Received: from smtp.kpnmail.nl (unknown [10.31.155.38]) by ewsoutbound.so.kpn.org (Halon) with ESMTPS id 803bdef9-7a0f-11ec-bb40-005056abad63; Thu, 20 Jan 2022 17:39:13 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xs4all.nl; s=xs4all01; h=from:to:subject:mime-version:date:message-id:content-type; bh=LP3G7P3Nrxtk4H+aad1JrOfIxrvR1z+BfZSojWsVP+A=; b=IXeXmMUh3a8uWC6lWytpk0yxToCagsFVEgmRFfem0KCiwjheW+s1RbFNFeERK8MPG3LB2gkE1fIT4 WVqCSVDWfjTOVnJAmlvhZj0fxlRhbkMkzLpJ0qXhjOtXK477EJjeDr84Ts+02F217Gig3fHBDHqn5E WsUJLX2+WY/aCtHrVihgOG6OlLm/EirG+5sK4zerdkVhAYz4h8hEkOo7MSQ5Th91k0AKs3Jf2WaYzt RrUhx4DAiLSopiYNt92iOzSVaDhgq4ea+HDXLToEpKQVlFBspnUKc08/sn6SRkCBDADUfivkilNcP6 NxwjILEkdciehLB6hl5YTOF2CCYCcrA== X-KPN-VerifiedSender: No X-CMASSUN: 33|wBhrgkVj5fpjWvNPVkUnscwjEoETpXd4ePmR//5K7BNr759cc6W/00Ago8FecMN 02G6VIvdRcyp510hl1cj8ow== X-Originating-IP: 213.125.29.162 Original-Received: from [10.100.1.103] (d57d1da2.static.ziggozakelijk.nl [213.125.29.162]) by smtp.xs4all.nl (Halon) with ESMTPSA id 82a0f35b-7a0f-11ec-8558-005056abf0db; Thu, 20 Jan 2022 17:39:17 +0100 (CET) Content-Language: en-US In-Reply-To: <36EDA4FC-F41E-43A6-8379-9AE4D53FDDA6@borisov.dev> X-BeenThere: ntg-context@ntg.nl X-Mailman-Version: 2.1.26 Precedence: list List-Id: mailing list for ConTeXt users List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ntg-context-bounces@ntg.nl Original-Sender: "ntg-context" Xref: news.gmane.io gmane.comp.tex.context:114225 Archived-At: This is a multi-part message in MIME format. --------------NFbFWqUpNH7kmm9oF9V7QiCN Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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 ----------------------------------------------------------------- --------------NFbFWqUpNH7kmm9oF9V7QiCN Content-Type: text/plain; charset=UTF-8; name="tabulated-002.tex" Content-Disposition: attachment; filename="tabulated-002.tex" Content-Transfer-Encoding: base64 XGRlZmluZWxpc3RhbHRlcm5hdGl2ZQ0KICBbd2hhdGV2ZXJdDQogIFtyZW5kZXJpbmdzZXR1 cD13aGF0ZXZlcl0NCg0KXHNldHVwbGlzdA0KICBbY2hhcHRlcl0NCiAgW2FsdGVybmF0aXZl PXdoYXRldmVyXQ0KDQpcc3RhcnRzZXR1cHMgd2hhdGV2ZXINCiAgICBcZnJhbWVkIFtvZmZz ZXQ9b3ZlcmxheSxmcmFtZT1vZmZdIHsNCiAgICAgICAgXGZyYW1lZCBbd2lkdGg9MjVtbSxh bGlnbj1mbHVzaGxlZnQsZnJhbWU9b2ZmLG9mZnNldD0wcHRdIHsNCiAgICAgICAgICAgIG51 bWJlcjogXGN1cnJlbnRsaXN0ZW50cnludW1iZXINCiAgICAgICAgfQ0KICAgICAgICBcZnJh bWVkIFt3aWR0aD00Y20sYWxpZ249bm9ybWFsLGZyYW1lPW9mZixvZmZzZXQ9MHB0XSB7DQ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gICAgICAgICAgICBjb250ZXh0LmVURCgpDQogICAgICAgICAg ICAgICAgICAgIGNvbnRleHQuYlREKCkNCiAgICAgICAgICAgICAgICAgICAgIC0tIGNvbnRl eHQoZW50cnkudGl0bGVkYXRhLnRpdGxlKQ0KICAgICAgICAgICAgICAgICAgICAgICAgc3Ry dWN0dXJlcy5saXN0cy50aXRsZShlbnRyeS5tZXRhZGF0YS5uYW1lLGkpDQogICAgICAgICAg ICAgICAgICAgIGNvbnRleHQuZVREKCkNCiAgICAgICAgICAgICAgICAgICAgY29udGV4dC5i VEQoKQ0KICAgICAgICAgICAgICAgICAgICAgICAgY29udGV4dChlbnRyeS51c2VyZGF0YS5t b3JlKQ0KICAgICAgICAgICAgICAgICAgICBjb250ZXh0LmVURCgpDQogICAgICAgICAgICAg ICAgY29udGV4dC5lVFIoKQ0KICAgICAgICAgICAgZW5kDQogICAgICAgIGNvbnRleHQuZVRB QkxFKCkNCiAgICBcc3RvcGx1YWNvZGUNClxzdG9wdGl0bGUNCg0KXHN0YXJ0Y2hhcHRlclt0 aXRsZT1PbmVdICBbbW9yZT1PTkVdICAgXHNhbXBsZWZpbGV7d2FyZH0gXHN0b3BjaGFwdGVy DQpcc3RhcnRjaGFwdGVyW3RpdGxlPVR3b10gIFttb3JlPVRXT10gICBcc2FtcGxlZmlsZXt3 YXJkfSBcc3RvcGNoYXB0ZXINClxzdGFydGNoYXB0ZXJbdGl0bGU9VGhyZWVdW21vcmU9VEhS RUVdIFxzYW1wbGVmaWxle3dhcmR9IFxzdG9wY2hhcHRlcg0KDQpcc3RvcHRleHQNCg== --------------NFbFWqUpNH7kmm9oF9V7QiCN Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX18KSWYgeW91ciBxdWVzdGlvbiBpcyBvZiBpbnRlcmVz dCB0byBvdGhlcnMgYXMgd2VsbCwgcGxlYXNlIGFkZCBhbiBlbnRyeSB0byB0aGUgV2lraSEKCm1h aWxsaXN0IDogbnRnLWNvbnRleHRAbnRnLm5sIC8gaHR0cDovL3d3dy5udGcubmwvbWFpbG1hbi9s aXN0aW5mby9udGctY29udGV4dAp3ZWJwYWdlICA6IGh0dHA6Ly93d3cucHJhZ21hLWFkZS5ubCAv IGh0dHA6Ly9jb250ZXh0LmFhbmhldC5uZXQKYXJjaGl2ZSAgOiBodHRwczovL2JpdGJ1Y2tldC5v cmcvcGhnL2NvbnRleHQtbWlycm9yL2NvbW1pdHMvCndpa2kgICAgIDogaHR0cDovL2NvbnRleHRn YXJkZW4ubmV0Cl9fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19f X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fCg== --------------NFbFWqUpNH7kmm9oF9V7QiCN--