Henning Hraban Ramm schrieb am 01.08.2020 um 22:16:

Am 01.08.2020 um 21:30 schrieb Wolfgang Schuster 
<wolfgang.schuster.li...@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).

\expanded needs a argument, i.e. \expanded{...}

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 mentioned only \index{\emph{...}} in your mail ...

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).


Hard to say without testing but the difference can be ignored because \index itself is what take processing time.

Wolfgang
___________________________________________________________________________________
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
___________________________________________________________________________________

Reply via email to