[NTG-context] How to manually adjust the sort order of items appearing in a custom index?
Henning Hraban Ramm
texml at fiee.net
Mon Jan 17 19:42:23 CET 2022
Am 17.01.22 um 16:53 schrieb Joel via ntg-context:
> I created a custom index that displays a list of "Important Dates"
> appearing in my book. It lists the year, a short description of what
> happened, and should show the page number.
>
> I'm running into two errors though:
>
> First, if the date is the same year, it is sorting alphabetically,
> example,,,,
>
> \dateis{1900s+1912}{Yet another event happened}
> \dateis{1900s+1912}{Another event happened}
>
> ...will print the wrong one first in the index..
>
> 1912 - Another even happened
> 1912 - Yet another event happened.
>
> Is there a way to manually tell it to display one first? I don't want to
> add visible month and day details, that would be even more confusing to
> the index as I have to print it in American order.
>
> Second, when it compiles it is not printing the page number, instead
> prints "[Entry not flushed]".
>
> -- Joel
>
> Here is my minimum working example:
>
>
> \defineregister[listdates][compress=yes]
> \setupregister[listdates][style=sansbold, textstyle=slanted, n=1,
> pagenumber=yes]
>
> \define[2]\dateis{%
> \listdates{#1~\emdash ~#2}%
> }%
>
> \starttext
>
> \dateis{1900s+1911}{Some event happened}
> \dateis{1900s+1912}{Yet another event happened}
> \dateis{1900s+1912}{Another event happened}
>
> \startchapter[title=Important Dates]
> \placelistdates
> \stopchapter
>
> \stoptext
Change your definition of \dateis (or use an additional macro) to use
the sort key of \index:
\index[1900s+191201]{January}
\index[1900s+191202]{February}
Hraban
More information about the ntg-context
mailing list