> On 24 Dec 2021, at 16:45, Jason Ross via ntg-context <ntg-context@ntg.nl> 
> wrote:
> 
> Dear list,
> 
> Is it possible to set the maximum table of contents depth to a number rather 
> than providing an explicit list of section names?
> 
> 
> Background:
> 
> I am developing an exporter for Org mode. In Org, users can specify the 
> number of levels they want in the table of contents with a number. I 
> currently do this by having the sectioning commands be known to the exporter 
> so I can generate a command like
>    \setupcombinedlist
>      [content]
>      [list={section,subsection}]
> for n=2.
> 
> I'm considering using  \start/stopsectionlevel for sectioning commands 
> instead. That way, users could add \definesectionlevels to the document 
> preamble to use whatever sectioning scheme they wanted. However, this would 
> mean that the exporter wouldn't know what sectioning commands to use the TOC 
> setup.

Can you not specify a full list of sections in your exporter code and then 
truncate that list to the appropriate value of n before generating the ConTeXt 
source from the truncated list?

Assuming you are using an Emacs macro to do the export then the following code 
will return the first 2 from the list of section types:

(let ((list '("part" "chapter" "section" "subsection" "subsubsection" 
"subsubsubsection" "subsubsubsubsection")))
  (butlast list (- (length list) 2)))

I stole that from StackOverflow so I'll leave it to you work out how to get 
your depth variable substituted for the 2. :-)

Note that you probably don't want "part" but I include it for completeness. 
Best to start with "chapter".
—
Bruce Horrocks
Hampshire, UK

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to