[NTG-context] consistent index entries
Henning Hraban Ramm
texml at fiee.net
Sat Aug 1 22:16:29 CEST 2020
> Am 01.08.2020 um 21:30 schrieb Wolfgang Schuster <wolfgang.schuster.lists at gmail.com>:
>> \def\Ort#1{\index{\ctxlua{user.Lookup("#1")}}}
>
> You have to expand the \index argument:
>
> \define[1]\Ort{\expanded{\index{...}}}
Ah, I never know where to expand (tried \expanded\ctxlua).
Now,
\def\TOrt#1{\expanded{\Ort{\ctxlua{userdata.Lookup("#1")}}}#1} % Loc + Text
\defineprocessor[kursiv][style=italicface]
\def\TFOrt#1{\expanded{\Ort[kursiv->]{\ctxlua{userdata.Lookup("#1")}}}#1} % Loc in Footnote + Text
works. :)
(I always define \TIndex to avoid doubling, e.g. Hamburg\index{Hamburg}.)
> When you use formatting commands etc. you have to use the optional argument for sorting.
I don’t understand.
\Ort[kursiv->]{Hamburg} works.
> You can avoid a few problems when you move the \index command to Lua and use context.index or you use a pure TeX solution.
>
> %%%% begin lua example
>
> function userdata.index(name)
> local indexentry = userdata.lookup[name] or name
> context.index(indexentry)
> end
That’s nice, but since I use different registers, I’d need to define that function for each. Since I also use several shortcuts (e.g. \TOrt, \TFOrt, \TPerson, \TFPerson) I would multiply the effort on the Lua side.
I find my TeX definitions (like above) shorter, where I can use the same Lua function for each.
With your code I could at least shorten it to:
function userdata.Lookup(name)
context(userdata.Lookups[name] or name)
end
> %%%% begin tex example
Oh, this is also nice. But isn’t the Lua version faster? (I have >600 person entries and a few hundred locations).
Thank you!
Hraban
More information about the ntg-context
mailing list