[NTG-context] check if inside footnote

Henning Hraban Ramm texml at fiee.net
Tue Aug 4 13:47:56 CEST 2020


> Am 04.08.2020 um 13:20 schrieb Hans Hagen <j.hagen at xs4all.nl>:
> 
> On 8/4/2020 11:04 AM, Henning Hraban Ramm wrote:
>> Hi, me again...
>> Is there a check if a macro is called from inside of a footnote, like a system mode *footnote?
>> (Same with captions?)
>> In my current project, index entries should get italic page numbers if they occurr inside of a footnote (or a caption, but that is rare).
>> I’m using different shortcuts for both cases (that call \index with or without processor), but some paragraphs are very confusing (many long footnotes, or footnotes within footnotes), and I could avoid manually analyzing the structure if my macro could determine on its own if it’s called from a footnote.
>> Not-working example:
>> \setupinteraction[state=start]
>> \defineprocessor[kursiv][style=italicface]
>> \define[1]\Idx{\doifmodeelse{*footnote}{\index{#1}}{\index[kursiv->]{kursiv->#1}}#1}
>> \starttext
>> Text
>> ---
>> \index[C]{A}{B}\footnote{Inside\index{FN}}\index{BF}
>> ---
>> \placeregister[index][criterium=all]
>> \stoptext
> bad MWE ... took me more time to se that \Idx was not used than this:

Ouch, sorry! That means I didn’t even check if that mode existed before; I also swapped the if/else brackets.


> \appendtoks
>    \setsystemmode\currentnote
> \to \everysynchronizenote
> 
> can you check if that works ok?

Yes, that works. Thank you very much!

i.e. MWE =

\setupinteraction[state=start]
\defineprocessor[kursiv][style=italicface]

\define[1]\Idx{\doifmodeelse{*footnote}{\index[kursiv->]{kursiv->#1}}{\index{#1}}#1}

\appendtoks
   \setsystemmode\currentnote
\to \everysynchronizenote

\starttext

Text

---
\index[C]{A}{B}\footnote{Inside\Idx{FN}}\Idx{BF}
---

\placeregister[index][criterium=all]

\stoptext



Hraban


More information about the ntg-context mailing list