ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Setting table of contents depth by number rather than by list
@ 2021-12-24 16:45 Jason Ross via ntg-context
  2021-12-24 17:42 ` Denis Maier via ntg-context
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Jason Ross via ntg-context @ 2021-12-24 16:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Jason Ross

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.


Thanks,

Jason
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 16:45 Setting table of contents depth by number rather than by list Jason Ross via ntg-context
@ 2021-12-24 17:42 ` Denis Maier via ntg-context
  2021-12-24 17:49   ` Denis Maier via ntg-context
  2021-12-24 23:35 ` Bruce Horrocks via ntg-context
  2021-12-25  0:00 ` Hans Hagen via ntg-context
  2 siblings, 1 reply; 14+ messages in thread
From: Denis Maier via ntg-context @ 2021-12-24 17:42 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Denis Maier

[-- Attachment #1: Type: text/html, Size: 3280 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 17:42 ` Denis Maier via ntg-context
@ 2021-12-24 17:49   ` Denis Maier via ntg-context
  2021-12-24 17:53     ` Jason Ross via ntg-context
  0 siblings, 1 reply; 14+ messages in thread
From: Denis Maier via ntg-context @ 2021-12-24 17:49 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Denis Maier

[-- Attachment #1: Type: text/html, Size: 3688 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 17:49   ` Denis Maier via ntg-context
@ 2021-12-24 17:53     ` Jason Ross via ntg-context
  2021-12-24 21:13       ` Denis Maier via ntg-context
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Ross via ntg-context @ 2021-12-24 17:53 UTC (permalink / raw)
  To: ntg-context; +Cc: Jason Ross



On 12/24/21 9:49 AM, Denis Maier via ntg-context wrote:
> For the six = for the toc...
>> Denis Maier via ntg-context <ntg-context@ntg.nl> hat am 24.12.2021 
>> 18:42 geschrieben:
>>
>>
>> Can't you just define a default structurelevel scheme and a default 
>> combined list for the six. If a user redefines the structure level 
>> scheme, they will just redefine the combined list as well. Would that 
>> work?
>>
>> Denis

The way the user specifies TOC depth in Org is e.g. "#+OPTIONS: toc:2". 
All exporters support that method.

Jason
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 17:53     ` Jason Ross via ntg-context
@ 2021-12-24 21:13       ` Denis Maier via ntg-context
  2021-12-24 21:20         ` Denis Maier via ntg-context
  0 siblings, 1 reply; 14+ messages in thread
From: Denis Maier via ntg-context @ 2021-12-24 21:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Denis Maier

[-- Attachment #1: Type: text/html, Size: 3398 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 21:13       ` Denis Maier via ntg-context
@ 2021-12-24 21:20         ` Denis Maier via ntg-context
  2021-12-24 21:22           ` Jason Ross via ntg-context
  0 siblings, 1 reply; 14+ messages in thread
From: Denis Maier via ntg-context @ 2021-12-24 21:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Denis Maier

[-- Attachment #1: Type: text/html, Size: 4196 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 21:20         ` Denis Maier via ntg-context
@ 2021-12-24 21:22           ` Jason Ross via ntg-context
  2021-12-24 21:29             ` Denis Maier via ntg-context
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Ross via ntg-context @ 2021-12-24 21:22 UTC (permalink / raw)
  To: ntg-context; +Cc: Jason Ross



On 12/24/21 1:20 PM, Denis Maier via ntg-context wrote:

>>
>> I see.
>>
>> Next try: add a new option
>>
>> "#+Context_Section_Levels:
>>
>> Thus will take an alist. Now you'll know about the user defined 
>> structure levels and the toc option can be translated to the 
>> corresponding setting. (Here again, you can if course define 
>> reasonable defaults.)
> 
> Actually,  you don't need an alist. A simple quotes list should be enough:
> 
> #+Context_Section_Levels: '(chapter section subsection)
>>
>> Denis


That isn't going to work. The interface needs to be the same as for the 
other exporters for TOC control. I need to support "toc:2".

Jason
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 21:22           ` Jason Ross via ntg-context
@ 2021-12-24 21:29             ` Denis Maier via ntg-context
  2021-12-24 21:37               ` Jason Ross via ntg-context
  0 siblings, 1 reply; 14+ messages in thread
From: Denis Maier via ntg-context @ 2021-12-24 21:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Denis Maier

[-- Attachment #1: Type: text/html, Size: 3461 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 21:29             ` Denis Maier via ntg-context
@ 2021-12-24 21:37               ` Jason Ross via ntg-context
  2021-12-24 21:43                 ` Denis Maier via ntg-context
  0 siblings, 1 reply; 14+ messages in thread
From: Jason Ross via ntg-context @ 2021-12-24 21:37 UTC (permalink / raw)
  To: Denis Maier, mailing list for ConTeXt users; +Cc: Jason Ross



On 12/24/21 1:29 PM, Denis Maier wrote:

> I probably wasn't clear. You will support toc:2.
> This:
> #+Context_Section_Levels: '(chapter section subsection)
> will translate into a definesectionlevels command and inform your 
> exporter about the used sectionlevels. Once the used commands are known 
> it should be possible to map toc:2 to a combinedlist definition.

I can't require the user to use more document keywords to get the same 
functionality they already have with the other exporters by default.

I am really specifically looking for a way _in ConTeXt_ to create a 
table of contents with depth `n` regardless of the sectioning used.

Jason
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 21:37               ` Jason Ross via ntg-context
@ 2021-12-24 21:43                 ` Denis Maier via ntg-context
  2021-12-24 21:48                   ` Denis Maier via ntg-context
  0 siblings, 1 reply; 14+ messages in thread
From: Denis Maier via ntg-context @ 2021-12-24 21:43 UTC (permalink / raw)
  To: Jason Ross, mailing list for ConTeXt users; +Cc: Denis Maier

[-- Attachment #1: Type: text/html, Size: 1941 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 21:43                 ` Denis Maier via ntg-context
@ 2021-12-24 21:48                   ` Denis Maier via ntg-context
  2021-12-24 21:55                     ` Jason Ross via ntg-context
  0 siblings, 1 reply; 14+ messages in thread
From: Denis Maier via ntg-context @ 2021-12-24 21:48 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Denis Maier

[-- Attachment #1: Type: text/html, Size: 2345 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 21:48                   ` Denis Maier via ntg-context
@ 2021-12-24 21:55                     ` Jason Ross via ntg-context
  0 siblings, 0 replies; 14+ messages in thread
From: Jason Ross via ntg-context @ 2021-12-24 21:55 UTC (permalink / raw)
  To: ntg-context; +Cc: Jason Ross

On 12/24/21 1:48 PM, Denis Maier via ntg-context wrote:
> Anyway, I agree that a solution via hierarchy levels would be nice.

That's what I'm hoping to achieve. I'm not familiar enough with 
low-level ConTeXt to do something like this but it seems like it ought 
to be possible.


>> You don't do that. If you provide default a default sectionlevel 
>> scheme, you'll know what toc:2 means.
>> If a user uses a different scheme provided via 
>> #+Context_Section_Levels you can use that to adjust the meaning of 
>> toc:2. But if a user uses the default setting toc:2 should be fine. 
>> Does that make sense?

I understand. The issue I see is that this introduces a coupling between 
section structure and table of contents that could be confusing for 
users, and also makes the interface more complicated by adding another 
keyword.

I am trying to take advantage of the flexibility of ConTeXt for most of 
the configuration, because a user is more likely to be familiar with 
ConTeXt than with my specific elisp module.


Jason
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 16:45 Setting table of contents depth by number rather than by list Jason Ross via ntg-context
  2021-12-24 17:42 ` Denis Maier via ntg-context
@ 2021-12-24 23:35 ` Bruce Horrocks via ntg-context
  2021-12-25  0:00 ` Hans Hagen via ntg-context
  2 siblings, 0 replies; 14+ messages in thread
From: Bruce Horrocks via ntg-context @ 2021-12-24 23:35 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Bruce Horrocks



> 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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: Setting table of contents depth by number rather than by list
  2021-12-24 16:45 Setting table of contents depth by number rather than by list Jason Ross via ntg-context
  2021-12-24 17:42 ` Denis Maier via ntg-context
  2021-12-24 23:35 ` Bruce Horrocks via ntg-context
@ 2021-12-25  0:00 ` Hans Hagen via ntg-context
  2 siblings, 0 replies; 14+ messages in thread
From: Hans Hagen via ntg-context @ 2021-12-25  0:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Hans Hagen

On 12/24/2021 5:45 PM, Jason Ross via ntg-context 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.
given the amount of reactions i added a simple levels feature ... the 
best i can do for now is:

\placelist[chapter,section,subsection][levels=2]

keep in mind that all should work with the already present selective 
placement and filtering (criterium)

uploaded

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2021-12-25  0:00 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-24 16:45 Setting table of contents depth by number rather than by list Jason Ross via ntg-context
2021-12-24 17:42 ` Denis Maier via ntg-context
2021-12-24 17:49   ` Denis Maier via ntg-context
2021-12-24 17:53     ` Jason Ross via ntg-context
2021-12-24 21:13       ` Denis Maier via ntg-context
2021-12-24 21:20         ` Denis Maier via ntg-context
2021-12-24 21:22           ` Jason Ross via ntg-context
2021-12-24 21:29             ` Denis Maier via ntg-context
2021-12-24 21:37               ` Jason Ross via ntg-context
2021-12-24 21:43                 ` Denis Maier via ntg-context
2021-12-24 21:48                   ` Denis Maier via ntg-context
2021-12-24 21:55                     ` Jason Ross via ntg-context
2021-12-24 23:35 ` Bruce Horrocks via ntg-context
2021-12-25  0:00 ` Hans Hagen via ntg-context

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).