ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Sanjoy Mahajan <sanjoy@olin.edu>
To: <ntg-context@ntg.nl>
Subject: getting metafun positions within (displayed) math mode
Date: Thu, 16 Nov 2017 16:10:10 -0500	[thread overview]
Message-ID: <874lpu53rh.fsf@olin.edu> (raw)

[-- Attachment #1: Type: text/plain, Size: 2457 bytes --]

Dear ConTeXters,

For my sins, and to make students unhappy all over the world, I am
writing another book: _A Student's Guide to Newton's Laws of Motion_
(for Cambridge University Press, aka CUP).  As partial compensation, I
convinced CUP that I may typeset it in ConTeXt and deliver them PDF.

Being hopefully a guide actually useful to students, it will annotate
every symbol in important equations, a feature cribbed from the first
book of the _Student's Guide_ series, Dan Fleisch's _A Student's Guide
to Maxwell's Equations_.

I've attached an image of what such an annotated equation looks like
(from page 2 of Fleisch's book).  It's like a labeled part diagram (say,
for a laptop), where each part (here, each symbol) is connected with an
line to its explanation.

I'm trying to do so with a combination of ConTeXt, MetaPost/MetaFun,
TikZ, and whatever else might work.  But I am a bit stuck at the
following spot.

My plan is to use MetaFun to get the coordinates of each symbol in a
(displayed) equation and then, with MetaFun, connect those symbols to
mini-paragraphs of explanation that surround the equation.

But I am stuck on how to use \hpos in math mode. I'd like to do
something like:

\startformula
\hpos{n1}{\sum}_{\hpos{n2}{0}}^{\hpos{n3}{1}}
\stopformula

to get the locations of the nodes n1, n2, and n3 without interfering
with the math typesetting -- e.g., the engine should still know that
\sum is in display-math mode, so it should be large and have its sub-
and super-scripts below and above it, rather than next to it.

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?

(TikZ seems to have the same issue, in that it cannot see into equations.)

Regards,
-- 
-Sanjoy

<http://savelongwharfpark.org/>
Save Long Wharf Park in Boston Harbor!

<http://streetfightingmath.com/>
Six reasoning tools to make hard problems easy.


[-- Attachment #2: example of an annotated equation --]
[-- Type: image/png, Size: 15242 bytes --]

[-- Attachment #3: Type: text/plain, Size: 492 bytes --]

___________________________________________________________________________________
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	other threads:[~2017-11-16 21:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-16 21:10 Sanjoy Mahajan [this message]
2017-11-17  7:46 ` Nigel King
2017-11-17 11:56 ` Aditya Mahajan
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=874lpu53rh.fsf@olin.edu \
    --to=sanjoy@olin.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).