ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* getting metafun positions within (displayed) math mode
@ 2017-11-16 21:10 Sanjoy Mahajan
  2017-11-17  7:46 ` Nigel King
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sanjoy Mahajan @ 2017-11-16 21:10 UTC (permalink / raw)
  To: ntg-context

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-17 19:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-16 21:10 getting metafun positions within (displayed) math mode Sanjoy Mahajan
2017-11-17  7:46 ` Nigel King
2017-11-17 11:56 ` Aditya Mahajan
2017-11-17 19:04 ` Sanjoy Mahajan

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).