Am 15.12.24 um 15:20 schrieb Bruce Horrocks:
On 13 Dec 2024, at 20:52, Henning Hraban Ramm
wrote: Hi, I’m trying to understand the ordering of list entries and find it really hard.
There might be a bug. With no order option specified the first \writebetweenlist is positioned after the following item. It appears correctly when order=command or order=all is specified.
Below is the content of "inbetween-01.tex" from the test suite, more or less the same was in https://wiki.contextgarden.ne/Command/writebetweenlist; I tried to enhance it but probably messed it up. Looking at the examples, I only partly understand what’s going on.
* What’s the difference of \writetolist and \writebetweenlist WRT their connection to the place where they occur? This seems to be important. (\writetolist has a section number, \writebetweenlist hasn’t …)
As far as I can tell the only difference is that \writebetweenlist has no number. Otherwise it appears in the list in the order it appears in the document source.
* What’s the difference between location="here", "none" or nothing with \writetolist?
From the comments in source of strc-lst.mkxl (line 105) it looks like it was something introduced to deal with an issue in mkiv that no longer applies? Hard to tell without comparing both versions in detail. I can't create a test example that shows a difference.
* In my notes, I found the remark that "between" items should be anchored to a paragraph (not being their own par) to avoid inserting whitespace.
Ditto re the source comments.
* The order of \placelist can be normal, command, all or title. The latter isn’t mentioned in the file below, but in the interface. I don’t understand the effect for "normal" or "all" in the example. - normal: there’s some reordering. - command: "only the commands": does this mean, sort the "between" entries by macro name or how? - all: everything in the order of occurrence (that’s clear) - title: sorted by title; how does this affect "between" entries?
I'm guessing that the text of between entries counts as the title for sorting purposes. Perhaps "here" was meant to attach to the previous \writetolist for sorting purposes?
I can't get sorting to work at all as per this example:
\definelist[testlist][criterium=all] \starttext
\subject{normal} \placelist[testlist]
\subject{order=command} \placelist[testlist][order=command]
\subject{order=all} \placelist[testlist][order=all]
\page
\writetolist[testlist]{2}{Second} \writebetweenlist[testlist]{betweenlist entry after second} The text of the second list item starts here. \page
\writetolist[testlist]{1}{First} \writebetweenlist[testlist]{betweenlist entry after first} The text of the first list item starts here.
\stoptext
Without "inbetween" entries: * order=title works for section titles, but not for an arbitrary "testlist". * I can’t find any effect of "order" on "testlist" With "inbetween" entries: * With order=title, the section order is totally messed up, and I still see no effect on the testlist. * With order=normal (or without "order"), injections get on top of the section list (which is in order of appearance); in the testlist not all inbetweens show up, order is unaffected. * With order=all or order=command, the order of normal and inbetween entries in both lists is "appearance"; I don’t see a difference. * \writebetweenlist with [location=here] stays in the right place, if order is not given, "normal" or "title". Conclusion: * order=title works only for section titles without injections. * Use order=all or order=command for lists with injections or location=here for each injection to keep their order of appearance. Hraban