ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* numbering questions
@ 2022-12-31 17:23 Henning Hraban Ramm via ntg-context
  2022-12-31 18:20 ` Duncan Hothersall via ntg-context
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2022-12-31 17:23 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Henning Hraban Ramm

A happy new year to everyone!

I’m playing with some examples of section numbering.

* Is there a setup to influence the order of number segments? I.e. can I 
have “section.chapter.part“ instead of “part.chapter.section”?

* How can I format the segments, e.g. to get two or three digits each 
(leading zeros)?

* I can force a section number with “ownnumber”, but the next one is 
back in the previous scheme. Itemize has “start”. How can I start 
section chapter numbering at 3 (or -1 or whatever; I know I can start at 
0 with “zero”) and let ConTeXt continue from there?


My example tries to (ab)use the section numbering for a date (e.g. for a 
diary):

-----
\definestructureconversionset[default][n,n,month,n][n]
\definestructureseparatorset [default][-,-,-,-]

\definehead[Year][chapter]
\definehead[Month][section]
\definehead[Day][subsection]

\define[2]\TitleCmd{#1} % number only

\setuphead[Year,Month,Day][number=yes,page=no,command=\TitleCmd]
\setuphead[Year][page=yes]
%\setuphead[Month][]
\setuphead[Day][style={\ss\bf}]

\def\Dummycontent{
     \dorecurse{12}{
     \startMonth
     New Month.

     \dorecurse{5}{
     \startDay
     Another day.

     \stopDay
     }

     \stopMonth
}}

\starttext

\startYear[ownnumber=2023,title=This]
A new year begins.

\Dummycontent

\stopYear

\startYear
Next year.

\Dummycontent

\stopYear

\stoptext
-----

Hraban

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

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

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

* Re: numbering questions
  2022-12-31 17:23 numbering questions Henning Hraban Ramm via ntg-context
@ 2022-12-31 18:20 ` Duncan Hothersall via ntg-context
  2022-12-31 19:36   ` Henning Hraban Ramm via ntg-context
  2022-12-31 19:41 ` Pablo Rodriguez via ntg-context
  2023-01-01 10:27 ` Wolfgang Schuster via ntg-context
  2 siblings, 1 reply; 7+ messages in thread
From: Duncan Hothersall via ntg-context @ 2022-12-31 18:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Duncan Hothersall


[-- Attachment #1.1: Type: text/plain, Size: 2338 bytes --]

I can't test right now but would something like

\setuphead[Day][sectionsegments=Day:Month:Year]

help?

Duncan


On Sat, 31 Dec 2022 at 17:24, Henning Hraban Ramm via ntg-context <
ntg-context@ntg.nl> wrote:

> A happy new year to everyone!
>
> I’m playing with some examples of section numbering.
>
> * Is there a setup to influence the order of number segments? I.e. can I
> have “section.chapter.part“ instead of “part.chapter.section”?
>
> * How can I format the segments, e.g. to get two or three digits each
> (leading zeros)?
>
> * I can force a section number with “ownnumber”, but the next one is
> back in the previous scheme. Itemize has “start”. How can I start
> section chapter numbering at 3 (or -1 or whatever; I know I can start at
> 0 with “zero”) and let ConTeXt continue from there?
>
>
> My example tries to (ab)use the section numbering for a date (e.g. for a
> diary):
>
> -----
> \definestructureconversionset[default][n,n,month,n][n]
> \definestructureseparatorset [default][-,-,-,-]
>
> \definehead[Year][chapter]
> \definehead[Month][section]
> \definehead[Day][subsection]
>
> \define[2]\TitleCmd{#1} % number only
>
> \setuphead[Year,Month,Day][number=yes,page=no,command=\TitleCmd]
> \setuphead[Year][page=yes]
> %\setuphead[Month][]
> \setuphead[Day][style={\ss\bf}]
>
> \def\Dummycontent{
>      \dorecurse{12}{
>      \startMonth
>      New Month.
>
>      \dorecurse{5}{
>      \startDay
>      Another day.
>
>      \stopDay
>      }
>
>      \stopMonth
> }}
>
> \starttext
>
> \startYear[ownnumber=2023,title=This]
> A new year begins.
>
> \Dummycontent
>
> \stopYear
>
> \startYear
> Next year.
>
> \Dummycontent
>
> \stopYear
>
> \stoptext
> -----
>
> Hraban
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> https://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : https://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : https://contextgarden.net
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 3413 bytes --]

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

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

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

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

* Re: numbering questions
  2022-12-31 18:20 ` Duncan Hothersall via ntg-context
@ 2022-12-31 19:36   ` Henning Hraban Ramm via ntg-context
  0 siblings, 0 replies; 7+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2022-12-31 19:36 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Henning Hraban Ramm

Am 31.12.22 um 19:20 schrieb Duncan Hothersall:
> I can't test right now but would something like
> \setuphead[Day][sectionsegments=Day:Month:Year]
> help?

I forgot to mention that I tried this. It doesn’t work (while it would 
be the most easy syntax, I guess), you can set the segments only in 
order of hierarchy.

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

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

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

* Re: numbering questions
  2022-12-31 17:23 numbering questions Henning Hraban Ramm via ntg-context
  2022-12-31 18:20 ` Duncan Hothersall via ntg-context
@ 2022-12-31 19:41 ` Pablo Rodriguez via ntg-context
  2022-12-31 21:07   ` Henning Hraban Ramm via ntg-context
  2023-01-01 10:27 ` Wolfgang Schuster via ntg-context
  2 siblings, 1 reply; 7+ messages in thread
From: Pablo Rodriguez via ntg-context @ 2022-12-31 19:41 UTC (permalink / raw)
  To: Henning Hraban Ramm via ntg-context; +Cc: Pablo Rodriguez

On 12/31/22 18:23, Henning Hraban Ramm via ntg-context wrote:
> I’m playing with some examples of section numbering.
> 
> * Is there a setup to influence the order of number segments? I.e. can I 
> have “section.chapter.part“ instead of “part.chapter.section”?

I thought sectionsegments=section:chapter would work, but it doesn’t.

> * How can I format the segments, e.g. to get two or three digits each 
> (leading zeros)?

The easy part is to have the leading zeros, but I cannot get it working
with numbercommand or deepnumbercommand.

  \startluacode
  function document.leadingzeros(str)
    local lzeros = 3-str:len()
    return ("0"):rep(lzeros)
  end
  \stopluacode
  \unexpanded\def\lzeros#1%
    {\cldcontext{document.leadingzeros("#1")}}

> * I can force a section number with “ownnumber”, but the next one is 
> back in the previous scheme. Itemize has “start”. How can I start 
> section chapter numbering at 3 (or -1 or whatever; I know I can start at 
> 0 with “zero”) and let ConTeXt continue from there?

\setupheadnumber[chapter][3] % will start with 4

I hope it helps. »Einen guten Rutsch ins Neujahr!«

Happy New Year to all!

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

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

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

* Re: numbering questions
  2022-12-31 19:41 ` Pablo Rodriguez via ntg-context
@ 2022-12-31 21:07   ` Henning Hraban Ramm via ntg-context
  0 siblings, 0 replies; 7+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2022-12-31 21:07 UTC (permalink / raw)
  To: ntg-context; +Cc: Henning Hraban Ramm

Am 31.12.22 um 20:41 schrieb Pablo Rodriguez via ntg-context:
> On 12/31/22 18:23, Henning Hraban Ramm via ntg-context wrote:
>> I’m playing with some examples of section numbering.
>>
>> * Is there a setup to influence the order of number segments? I.e. can I
>> have “section.chapter.part“ instead of “part.chapter.section”?
> 
> I thought sectionsegments=section:chapter would work, but it doesn’t.
> 
>> * How can I format the segments, e.g. to get two or three digits each
>> (leading zeros)?
> 
> The easy part is to have the leading zeros, but I cannot get it working
> with numbercommand or deepnumbercommand.
> 
>    \startluacode
>    function document.leadingzeros(str)
>      local lzeros = 3-str:len()
>      return ("0"):rep(lzeros)
>    end
>    \stopluacode
>    \unexpanded\def\lzeros#1%
>      {\cldcontext{document.leadingzeros("#1")}}

Same. With numbercommand, Lua gets "\s and can’t handle it, with 
deepnumbercommand it gets "1-\m". Is this a catcode issue?


>> * I can force a section number with “ownnumber”, but the next one is
>> back in the previous scheme. Itemize has “start”. How can I start
>> section chapter numbering at 3 (or -1 or whatever; I know I can start at
>> 0 with “zero”) and let ConTeXt continue from there?
> 
> \setupheadnumber[chapter][3] % will start with 4

Thank you, that works.

> I hope it helps. »Einen guten Rutsch ins Neujahr!«

Dito!

(In proper German that would be just “Guten Rutsch” or “Guten Rutsch ins 
neue Jahr”; Neujahr ist just the name of the holiday.)

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

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

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

* Re: numbering questions
  2022-12-31 17:23 numbering questions Henning Hraban Ramm via ntg-context
  2022-12-31 18:20 ` Duncan Hothersall via ntg-context
  2022-12-31 19:41 ` Pablo Rodriguez via ntg-context
@ 2023-01-01 10:27 ` Wolfgang Schuster via ntg-context
  2023-01-01 13:13   ` Henning Hraban Ramm via ntg-context
  2 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster via ntg-context @ 2023-01-01 10:27 UTC (permalink / raw)
  To: mailing list for ConTeXt users, Henning Hraban Ramm via ntg-context
  Cc: Wolfgang Schuster

Henning Hraban Ramm via ntg-context schrieb am 31.12.2022 um 18:23:
> A happy new year to everyone!
>
> I’m playing with some examples of section numbering.
>
> * Is there a setup to influence the order of number segments? I.e. can 
> I have “section.chapter.part“ instead of “part.chapter.section”?

You need a new prefix-set to rearrange the order of the sections.

%%%% begin example
\defineprefixset [reverse-section]    [section,chapter] []
\defineprefixset [reverse-subsection] [subsection,section,chapter] []

\setuphead
   [section]
   [sectionset=reverse-section]

\setuphead
   [subsection]
   [sectionset=reverse-subsection]

\starttext

\startchapter [title={A}]

\startsection [title={B}]

\startsubsection [title={C}] \stopsubsection
\startsubsection [title={D}] \stopsubsection
\startsubsection [title={E}] \stopsubsection

\stopsection

\startsection [title={F}]

\startsubsection [title={G}] \stopsubsection
\startsubsection [title={H}] \stopsubsection
\startsubsection [title={I}] \stopsubsection

\stopsection

\stopchapter

\stoptext
%%%% end example

> * How can I format the segments, e.g. to get two or three digits each 
> (leading zeros)?

You can create your own conversion format.

%%%% begin example
\startluacode
interfaces.implement {
     name      = "FourDigits",
     public    = true,
     arguments = "string",
     actions   = function(s) context("%04d",tonumber(s)) end
}
\stopluacode

\defineconversion [FourDigits] [\FourDigits]

\setuphead
   [chapter]
   [conversion=FourDigits]

\starttext

\startchapter [title={Chapter}] \stopchapter

\stoptext
%%%% end example

Wolfgang

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

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

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

* Re: numbering questions
  2023-01-01 10:27 ` Wolfgang Schuster via ntg-context
@ 2023-01-01 13:13   ` Henning Hraban Ramm via ntg-context
  0 siblings, 0 replies; 7+ messages in thread
From: Henning Hraban Ramm via ntg-context @ 2023-01-01 13:13 UTC (permalink / raw)
  To: mailing list for ConTeXt users; +Cc: Henning Hraban Ramm

Thank you, Wolfgang!
I _knew_ ConTeXt would be able to handle my requirements! ;D
It’s wikified now (at \setuphead and \defineconversion).

Hraban

Am 01.01.23 um 11:27 schrieb Wolfgang Schuster:
> Henning Hraban Ramm via ntg-context schrieb am 31.12.2022 um 18:23:
>> A happy new year to everyone!
>>
>> I’m playing with some examples of section numbering.
>>
>> * Is there a setup to influence the order of number segments? I.e. can 
>> I have “section.chapter.part“ instead of “part.chapter.section”?
> 
> You need a new prefix-set to rearrange the order of the sections.
> 
> %%%% begin example
> \defineprefixset [reverse-section]    [section,chapter] []
> \defineprefixset [reverse-subsection] [subsection,section,chapter] []
> 
> \setuphead
>    [section]
>    [sectionset=reverse-section]
> 
> \setuphead
>    [subsection]
>    [sectionset=reverse-subsection]
> 
> \starttext
> 
> \startchapter [title={A}]
> 
> \startsection [title={B}]
> 
> \startsubsection [title={C}] \stopsubsection
> \startsubsection [title={D}] \stopsubsection
> \startsubsection [title={E}] \stopsubsection
> 
> \stopsection
> 
> \startsection [title={F}]
> 
> \startsubsection [title={G}] \stopsubsection
> \startsubsection [title={H}] \stopsubsection
> \startsubsection [title={I}] \stopsubsection
> 
> \stopsection
> 
> \stopchapter
> 
> \stoptext
> %%%% end example
> 
>> * How can I format the segments, e.g. to get two or three digits each 
>> (leading zeros)?
> 
> You can create your own conversion format.
> 
> %%%% begin example
> \startluacode
> interfaces.implement {
>      name      = "FourDigits",
>      public    = true,
>      arguments = "string",
>      actions   = function(s) context("%04d",tonumber(s)) end
> }
> \stopluacode
> 
> \defineconversion [FourDigits] [\FourDigits]
> 
> \setuphead
>    [chapter]
>    [conversion=FourDigits]
> 
> \starttext
> 
> \startchapter [title={Chapter}] \stopchapter
> 
> \stoptext
> %%%% end example
> 
> Wolfgang
> 

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

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

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

end of thread, other threads:[~2023-01-01 13:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-31 17:23 numbering questions Henning Hraban Ramm via ntg-context
2022-12-31 18:20 ` Duncan Hothersall via ntg-context
2022-12-31 19:36   ` Henning Hraban Ramm via ntg-context
2022-12-31 19:41 ` Pablo Rodriguez via ntg-context
2022-12-31 21:07   ` Henning Hraban Ramm via ntg-context
2023-01-01 10:27 ` Wolfgang Schuster via ntg-context
2023-01-01 13:13   ` Henning Hraban Ramm 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).