> On 13 Mar 2026, at 21:25, Matthias Weber <[email protected]> wrote:
> 
> Hello,
> 
> I have a document with ~30 chapters, one for each date of a certain day that 
> changes from year to year. 
> So I wanted to put the list of dates at the top of the document, where I can 
> locate and update them easily, 
> and process the list using a little Lua, like so:
> 
> 
> \setupheadertexts[\getmarking[section]]
> 
> \def \day{\ctxlua{tex.print(classdates[i]) i=i+1}}
> %\def\day{}
> \ctxlua
>  { classdates = {"May 12", "May 13", "May 14", "May 15"}
>   i=1}
> 
> 
> \completecontent
> 
> \starttext
> 
> \section{Math (\day)}
> \section{More Math (\day)}
> \section{The End (\day)}
> 
> 
> \stoptext
> 
> 
> Unfortunately, the Lua code is already processed for the table of contents, 
> so I ran out of dates in the \section commands. 
> A simple hack could be to let Lua go through the list twice — but this 
> doesn’t help, as I am also using the name of a section in the header, where 
> the counter is being increased
> an undetermined number of times, once for each new page.
> 
> Is there a way to fix this?

This?

\setvariables
  [classdates]
  [1="May 12",
   2="May 13",
   3="May 14",
   4="May 15"]

\def\day{\getvariable{classdates}{\somenamedheadnumber{section}{current}}}

\completecontent

\starttext

\section{Math (\day)}
\section{More Math (\day)}
\section{The End (\day)}

\stoptext



—
Bruce Horrocks
Hampshire, UK

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

maillist : [email protected] / 
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage  : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive  : https://github.com/contextgarden/context
wiki     : https://wiki.contextgarden.net
___________________________________________________________________________________

Reply via email to