Wrt formatting (e.g. \index{\emph{something}}), the garden also mentions processors for MkIV (https://wiki.contextgarden.net/Registers#Processors), so you can wrap them with custom commands, in case it helps. Cordially, Jairo. El sáb., 1 de ago. de 2020 a la(s) 14:01, Jairo A. del Rio ( jairoadelrio6@gmail.com) escribió:
Hi, Henning. According to the garden, something like:
\def\Ort#1{\index[#1]{\ctxlua{user.Lookup("#1")}}}
as long as #1 is capable of being sorted in the normal way, should work.
Regards,
Jairo
El sáb., 1 de ago. de 2020 a la(s) 13:49, Henning Hraban Ramm ( texml@fiee.net) escribió:
Am 01.08.2020 um 13:22 schrieb Henning Hraban Ramm
: Hi,
besides the CG journal I’m working on a scientific biography with huge person and locality indexes (named Person and Locality for the examples).
In many cases, the author wants additional information in the index, e.g.
\Locality{Altona (Hamburg)} \Locality{Breslau (pol. Wrocław)} or \Person{Arends, Katharina (née Schoemaker)} \Person{Wilhelm II. (Kaiser)}
Now, I need that consistent and I don’t want to type these complicated entries every time.
I’m looking for a good way to handle this – maybe a lookup table in Lua, so that \LookupPerson{Willy II} would call a Lua function that returns \Person{Wilhelm II. (Kaiser)} ?
Or is there already something in place that I overlooked, like \OverwriteIndexEntry{Hraban}{Ramm, Henning Hraban} ?
I came up with:
\startluacode user.Lookups = { ["Albano"] = "Albano (Provinz Rom)", ["Altona"] = "Altona (Hamburg)", ["Aurich"] = "Aurich (Ostfriesland)" }
function user.Lookup(Name) local Res = user.Lookups[Name] if Res then return context(Res) else return context(Name) end end \stopluacode
\def\Ort#1{\index{\ctxlua{user.Lookup("#1")}}}
\starttext
\Ort{Albano} \Ort{Altona} \Ort{Aurich} \strut\page
\placeindex
\stoptext
The lookup works so far, but all the entries get sorted unter C (because of \ctxlua).
I remember I had the same problem with other macros (like \index{\emph{bla}}), but can’t find a solution in my usual sources.
Hraban
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://context.aanhet.net archive : https://bitbucket.org/phg/context-mirror/commits/ wiki : http://contextgarden.net
___________________________________________________________________________________