On Thu, 16 Nov 2017, Sanjoy Mahajan wrote:

However, the \hpos hides its argument in an \hbox, and thus hides it
from the math layout.  Thus, I have to do something like this minimal
example:

\starttext
\startformula
 \sum_0^1                      % what it should look like
 \quad
 \hpos{n1}{$\displaystyle\sum$}_{\hpos{n2}{$0$}}^{\hpos{n3}{$1$}}
\stopformula
\stoptext

The hpos'ed version after the \quad looks different, even after the
\displaystyle hack.

Is there a version of \hpos for math mode?  That would be the cleanest
solution, because who knows what else would be needed for other cases,
even if the limits can be placed correctly.

Or is there a better way to annotate equations?

No time for a detailed answer, but what you need is the following:

\starttext
\startformula
  \sum_0^1                      % what it should look like
  \quad
  
\mathop{\hpos{n1}{\mathsurround\zeropoint$\displaystyle\sum$}}_{\hpos{n2}{\mathsurround\zeropoint$\scriptstyle0$}}^{\hpos{n3}{\mathsurround\zeropoint$\scriptstyle1$}}
\stopformula
\stoptext

So what you need to do is find the mathmode of the current symbol (mathbin, mathord, etc) and find the mathstyle of the current symbol (\displaystyle, \scriptstyle, \scriptscriptstyle, etc), and reapply those.

There is some code in the core to do detect whether the current symbol is a bin or not (and perhaps that can be adapted to see if the current symbol is an op or not). But a simpler solution will be use luatex to traverse the mathlist after it has been typeset (but I don't understand who that works).

Of course, an ideal solution will be to define a macro \mpos{...} that does this behind the scenes.

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