[NTG-context] Re: chronological TOC

2024-01-29 Thread jbf
And indeed this is the best solution I could find, though it obviously 
meant that something like '29 April 2017' was no good for sorting on... 
it has to be the US date format YY-MM-DD


Julian

On 30/1/24 06:15, Wolfgang Schuster wrote:

Henning Hraban Ramm schrieb am 27.01.2024 um 10:05:

Am 26.01.24 um 23:46 schrieb jbf:
I wonder if someone can point me in the right direction for a 
separate TOC which needs to be in chronological order at the back of 
the book (i.e. not in page number order, although I need the page 
numbers to show up in the TOC. There is the normal TOC at the front 
of the book, according to chapter titles.


I have succeeded in defining a separate TOC to place at the back, 
but have not succeeded in the chronological order! Here is what I 
have done:


\definelist[chron][criterium=all,alternative=c]

At the back of the book:

\placelist[chron][criterium=all]

Then at an appropriate point after each \startchapter I have placed 
(as an example):


\writetolist[chron]{}{{\bf 29 April 2017,} Speech, Panama City}

This gives me my list, but in page number order. How do I get the 
date (e.g. 29 April 2017) to be the ordering factor in the list. I 
assume it will be something to do with criterium, but am clueless at 
the moment on how to indicate this.


I don’t know if it works this way (the wizards will know a way), but 
for special needs I’m (ab)using indexes:
just add something like \index[2017-04-29]{Speech, Panama City} to 
your chapter command and setup the index at will.


Lists have a sort option but this is no use here because you can't use 
the title to have a chronological sorted list.


\starttext

\placelist[section][order=title]

\section{Hans}

\section{Peter}

\section{Anton}

\stoptext

Using the register mechanism as you suggest seems to be the best 
option in this case.


Wolfgang
___ 

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


maillist : ntg-context@ntg.nl / 
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
___ 


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

maillist : ntg-context@ntg.nl / 
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
___


[NTG-context] Re: chronological TOC

2024-01-29 Thread Bruce Horrocks
On 29 Jan 2024, at 19:15, Wolfgang Schuster  
wrote:
> 
> Henning Hraban Ramm schrieb am 27.01.2024 um 10:05:
>> Am 26.01.24 um 23:46 schrieb jbf:
>>> I wonder if someone can point me in the right direction for a separate TOC 
>>> which needs to be in chronological order at the back of the book (i.e. not 
>>> in page number order, although I need the page numbers to show up in the 
>>> TOC. There is the normal TOC at the front of the book, according to chapter 
>>> titles.
>>> 
>>> I have succeeded in defining a separate TOC to place at the back, but have 
>>> not succeeded in the chronological order! Here is what I have done:
>>> 
>>> \definelist[chron][criterium=all,alternative=c]
>>> 
>>> At the back of the book:
>>> 
>>> \placelist[chron][criterium=all]
>>> 
>>> Then at an appropriate point after each \startchapter I have placed (as an 
>>> example):
>>> 
>>> \writetolist[chron]{}{{\bf 29 April 2017,} Speech, Panama City}
>>> 
>>> This gives me my list, but in page number order. How do I get the date 
>>> (e.g. 29 April 2017) to be the ordering factor in the list. I assume it 
>>> will be something to do with criterium, but am clueless at the moment on 
>>> how to indicate this.
>> I don’t know if it works this way (the wizards will know a way), but for 
>> special needs I’m (ab)using indexes:
>> just add something like \index[2017-04-29]{Speech, Panama City} to your 
>> chapter command and setup the index at will.
> 
> Lists have a sort option but this is no use here because you can't use the 
> title to have a chronological sorted list.
> 
> \starttext
> 
> \placelist[section][order=title]
> 
> \section{Hans}
> 
> \section{Peter}
> 
> \section{Anton}
> 
> \stoptext
> 
> Using the register mechanism as you suggest seems to be the best option in 
> this case.

The order= mechanism doesn't seem to work for \definelist lists as opposed to 
the built-in ones, viz:

\definelist[chron]
\starttext

\placelist[section][order=title]

\section{Hans}
\writetolist[chron]{}{Hans}

\section{Peter}
\writetolist[chron]{}{Peter}

\section{Anton}
\writetolist[chron]{}{Anton}

\placelist[chron][criterium=all,order=title]
\stoptext


—
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 / 
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
___


[NTG-context] Re: chronological TOC

2024-01-29 Thread Wolfgang Schuster

Henning Hraban Ramm schrieb am 27.01.2024 um 10:05:

Am 26.01.24 um 23:46 schrieb jbf:
I wonder if someone can point me in the right direction for a separate 
TOC which needs to be in chronological order at the back of the book 
(i.e. not in page number order, although I need the page numbers to 
show up in the TOC. There is the normal TOC at the front of the book, 
according to chapter titles.


I have succeeded in defining a separate TOC to place at the back, but 
have not succeeded in the chronological order! Here is what I have done:


\definelist[chron][criterium=all,alternative=c]

At the back of the book:

\placelist[chron][criterium=all]

Then at an appropriate point after each \startchapter I have placed 
(as an example):


\writetolist[chron]{}{{\bf 29 April 2017,} Speech, Panama City}

This gives me my list, but in page number order. How do I get the date 
(e.g. 29 April 2017) to be the ordering factor in the list. I assume 
it will be something to do with criterium, but am clueless at the 
moment on how to indicate this.


I don’t know if it works this way (the wizards will know a way), but for 
special needs I’m (ab)using indexes:
just add something like \index[2017-04-29]{Speech, Panama City} to your 
chapter command and setup the index at will.


Lists have a sort option but this is no use here because you can't use 
the title to have a chronological sorted list.


\starttext

\placelist[section][order=title]

\section{Hans}

\section{Peter}

\section{Anton}

\stoptext

Using the register mechanism as you suggest seems to be the best option 
in this case.


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

maillist : ntg-context@ntg.nl / 
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
___


[NTG-context] Re: Own command definition breaks with interaction: Use of \do_my_command doesn't match its definition

2024-01-29 Thread Wolfgang Schuster

Gerion Entrup schrieb am 25.01.2024 um 09:18:

Hi,

I want to make a proper definition of a new command to be able to
process it in Lua. I found something on StackOverflow [1] but that
breaks in enumeration _and_ when interaction is enabled and I do not
understand why? Can you give me some help here?

I want to make commands like \foo{bla} and \foo[b]{bla} possible at the
same time. Here is a minimal example (also attached):

```
\startluacode
function userdata.my_command(keywords, text)
commands.writestatus("test", string.format("text: %s, config: %s", 
text, keywords))
 local cfg = utilities.parsers.settings_to_hash(keywords)

if cfg['emph'] ~= nil then
context("\\emph{" .. text .. "}")
elseif cfg['bold'] ~= nil then
context("\\bold{" .. text .. "}")
else
context(text)
end
end
\stopluacode


\startluacode
function userdata.my_command(keywords, text)
  local keywords = utilities.parsers.settings_to_hash(keywords)
  if keywords['emph'] then
context.emph(text)
  elseif keywords['bold'] then
context.bold(text)
  else
context(text)
  end
end
\stopluacode


% without that line there is no problem
\setupinteraction[state=start]

\defineenumeration[enu][text=Enu]


\defineenumeration[enu][text=Enu,title=yes]


\unprotect
\def\mc{\dosingleempty\do_my_command}
\def\do_my_command[#1]#2{%
\iffirstargument{%
\ctxlua{userdata.my_command('#1', [==[#2]==])}%
}\else {%
\ctxlua{userdata.my_command('', [==[#2]==])}%
}\fi
}
\protect


\tolerant\protected\def\mc[#1]#2%
  {\ctxlua{userdata.my_command("#1","#2")}}

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

maillist : ntg-context@ntg.nl / 
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
___


[NTG-context] Re: mtxrun.lua:10080: bad argument #9 to 'format'

2024-01-29 Thread Hans Hagen

On 1/29/2024 12:08 PM, Taco Hoekwater wrote:


Hi,

I changed line 10066 in mtxrun.lua to

  templates[i]="%-"..w.."s"..between

from

  templates[i]=“% "..w..”i"..between

and that fixed it.


thanks, I also changed util-fmt.lua line 79

Hans

-
  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 / 
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
___


[NTG-context] Re: mtxrun.lua:10080: bad argument #9 to 'format'

2024-01-29 Thread Taco Hoekwater


> On 29 Jan 2024, at 01:36, vm via ntg-context  wrote:
> 
> while also on linux platform:
> 
> 
> mtxrun --script font --list --spec --filter="fontname=ibm*"
> mtxrun --script font --list --spec --filter="fontname=ple*"
> 
> give correct result (as in listing the available installed ibmplex fonts)
> 
> 
> mtxrun --script font --list --spec --filter="fontname=*"
> mtxrun --script font --list --spec --filter="fontname=p*"
> mtxrun --script font --list --spec --filter="fontname=pl*"
> 
> lua error : function call: 
> /home/vm/context/tex/texmf-linux-64/bin/mtxrun.lua:10080: bad argument #9 to 
> 'format' (number expected, got string)
> 
> apparently you need at least three characters in the the filter template.

Hi,

I changed line 10066 in mtxrun.lua to

 templates[i]="%-"..w.."s"..between

from 

 templates[i]=“% "..w..”i"..between

and that fixed it.

The problem here is that the “big" results contain both ttc fonts (with subfont 
ids, which are numbers) and non-ttc fonts (with empty subfont ids, and those 
are strings).
This means the output template gets confused about whether it should use “%s” 
or “%i” as format string.

> 
> 
> 
> $ mtxrun --script font --list --spec --filter="fontname=ple"
> table: 0x3bc80550ac0
> table: 0x3bc80550b00

This is what happens if there are no matches, apparently.


Best wishes,
Taco

— 
Taco Hoekwater  E: t...@bittext.nl
genderfluid (all pronouns)


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

maillist : ntg-context@ntg.nl / 
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
___


[NTG-context] Re: Own command definition breaks with interaction: Use of \do_my_command doesn't match its definition

2024-01-29 Thread Taco Hoekwater
Hi,

You can try: 

> \unexpanded\def\do_my_command[#1]#2{%

But there is probably a cleaner way to implement optional arguments with lua?

Best wishes,
Taco

> On 25 Jan 2024, at 09:18, Gerion Entrup  wrote:
> 
> Hi,
> 
> I want to make a proper definition of a new command to be able to
> process it in Lua. I found something on StackOverflow [1] but that
> breaks in enumeration _and_ when interaction is enabled and I do not
> understand why? Can you give me some help here?
> 
> I want to make commands like \foo{bla} and \foo[b]{bla} possible at the
> same time. Here is a minimal example (also attached):
> 
> ```
> \startluacode
> function userdata.my_command(keywords, text)
> commands.writestatus("test", string.format("text: %s, config: %s", text, 
> keywords))
>local cfg = utilities.parsers.settings_to_hash(keywords)
> 
> if cfg['emph'] ~= nil then
> context("\\emph{" .. text .. "}")
> elseif cfg['bold'] ~= nil then
> context("\\bold{" .. text .. "}")
> else
> context(text)
> end
> end
> \stopluacode
> 
> % without that line there is no problem
> \setupinteraction[state=start]
> 
> \defineenumeration[enu][text=Enu]
> 
> \unprotect
> \def\mc{\dosingleempty\do_my_command}
> \def\do_my_command[#1]#2{%
> \iffirstargument{%
> \ctxlua{userdata.my_command('#1', [==[#2]==])}%
> }\else {%
> \ctxlua{userdata.my_command('', [==[#2]==])}%
> }\fi
> }
> \protect
> 
> \starttext
> 
> % all the following works
> \mc{foo} \mc[bold]{foo} \mc[emph]{foo}
> 
> \startenu[title=Some]
> \stopenu
> 
> % this breaks
> \startenu[title=Some \mc{foo}]
> \stopenu
> 
> \stoptext
> ```
> 
> The compilation fails with:
> ```
> tex error   > tex error on line 41 in file ./test.tex: Use of 
> \do_my_command doesn't match its definition
> ```
> 
> Best,
> Gerion
> 
> [1] https://tex.stackexchange.com/a/55778
> ___
> If your question is of interest to others as well, please add an entry to the 
> Wiki!
> 
> maillist : ntg-context@ntg.nl / 
> 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
> ___

— 
Taco Hoekwater  E: t...@bittext.nl
genderfluid (all pronouns)


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

maillist : ntg-context@ntg.nl / 
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
___