For total number of pages, one can use \lastcounter[userpage]
to get the total number of pages in the document. Actually it gives the number on the last page (which is more interesting). Similar commands work for the total number of formulas, figures, etc. in the document.
How can I get the number of chapters? Inspecting structures.counters
in Lua doesn't show a counter associated with chapter numbering.
Here is my use case in particular: I have sections and subsections and I have arranged for the numbering of the latter not to get reset at each new section. I want to have the total number of subsections in my document: "5" in the example below.
Section 1 Subsection 1 Subsection 2 Section 2 Subsection 3 Subsection 4 Subsection 5
The command \somenamedheadnumber{subsection}{last}
provides the last subsection number within the currently active structure (current section in my case), but I could not find a way to get the very last value for the entire document.
In TeX/LaTeX I would add a hook to \subsection
to log the counter value to a file and then read that file at the beginning of the document to compute the final value. (This simplifies a bit if one uses \AtEndDocument
in LaTeX.) I'm sure there is a simple way to do this in CONTEXT but I could not find it.