[NTG-context] \hpos in math - Half solved

Gavin gavinpublic at comcast.net
Wed Dec 7 13:42:41 CET 2022

Hi List,

I solved my original problem 2, allowing me to reuse the same \hpos labels in different equations without interference. I added an equation counter and set up my custom math version of \hpos to use the count as part of the label internally. I tried to do this with a regular ConTeXt counter, but had all sorts of mysterious, wrong behavior. When I switched to using a Lua counter, everything worked immediately. So, while there is nothing brilliant about this solution, I’ll share it for anyone who might want to do something similar in the future.

The code I added is below, with some comments. The complete example file is attached. The result is two equations.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hposQuestionEquations.pdf
Type: application/pdf
Size: 6141 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20221207/bc10ca0e/attachment.pdf>
-------------- next part --------------

Each equation was written using the same labels (X,Y,Z), but internally they have separate sets, (1:X and 2:X, etc.).

The moral of the story for me: Use more Lua.


% Lua counts the spin formulas 
\ctxlua{sfnum = 0} % Count starts at zero
\def\sfID{\ctxlua{context(sfnum)}} % ConTeXt can call the count from Lua to use as an ID for each equation.

% Spin formulas increase the spin formula count and typeset the formula as usual.
  \ctxlua{sfnum = sfnum + 1}

% My own \mpos uses the spin formula ID as part of the box label, then sets the contents as math.

% Two commands for requesting contractions (the connections between spinors), using the spin formula ID.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: hposQuestion.tex
Type: application/octet-stream
Size: 3796 bytes
Desc: not available
URL: <http://mailman.ntg.nl/pipermail/ntg-context/attachments/20221207/bc10ca0e/attachment.obj>

More information about the ntg-context mailing list