ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Aditya Mahajan <adityam@umich.edu>
To: mailing list for ConTeXt users <ntg-context@ntg.nl>
Subject: Re: getting metafun positions within (displayed) math mode
Date: Fri, 17 Nov 2017 06:56:25 -0500 (EST)	[thread overview]
Message-ID: <alpine.OSX.2.03.1711170652270.24312@zptvyy.pn> (raw)
In-Reply-To: <874lpu53rh.fsf@olin.edu>

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
___________________________________________________________________________________

  parent reply	other threads:[~2017-11-17 11:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 21:10 Sanjoy Mahajan
2017-11-17  7:46 ` Nigel King
2017-11-17 11:56 ` Aditya Mahajan [this message]
2017-11-17 19:04 ` Sanjoy Mahajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.OSX.2.03.1711170652270.24312@zptvyy.pn \
    --to=adityam@umich.edu \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).