From: Hans Hagen via ntg-context <ntg-context@ntg.nl>
To: Gavin via ntg-context <ntg-context@ntg.nl>
Cc: Hans Hagen <j.hagen@freedom.nl>
Subject: Re: Mathematical MetaFun Mania
Date: Thu, 15 Dec 2022 11:36:55 +0100 [thread overview]
Message-ID: <8f54f916-907b-12cf-9525-ff4a40665ae2@freedom.nl> (raw)
In-Reply-To: <D8112EA9-9F8A-4607-961B-8EAB42B8EAD1@comcast.net>
[-- Attachment #1: Type: text/plain, Size: 3260 bytes --]
On 12/15/2022 4:20 AM, Gavin via ntg-context wrote:
> Hello MetaFun Math Lovers,
>
> I am using MetaFun to attach diagrams to formulas. Both the physics and the typesetting are going great! I attached a sample below, to give a taste of what I am trying to do. This page of actual calculations has examples of almost everything I need. It’s a lot, but it is all working. Right now the interface is terrible, but effective. Thanks to Hans and Mikael for many helpful hints!
>
> I am still using \hpos and \setMPpositiongraphic, because I haven't figured out how to pass information from \mathboxanchored and \connectboxanchors to my MetaPost code. Here is the code for the connectors:
>
> \startMPpositiongraphic{mypos:contract}
> path pa, pb, pab ; numeric na, nb ; string ta, tb, hand, product ;
> ta := mpvars("from") ;
> tb := mpvars("to") ;
> stemshiftfrom := (EmWidth/8)*mpvarn("startstem") ;
> stemshiftto := (EmWidth/8)*mpvarn("stopstem") ;
> hand := mpvars("hand") ;
> product := mpvars("product") ;
> delta := mpvard("distance") ;
> na := positionpage(ta) ; % page number of a
> nb := positionpage(tb) ; % page number of b
> pa := positionbox(ta) ; % box of a
> pb := positionbox(tb) ; % box of b
> if hand = "right" :
> z1 = 0.5[llcorner pa,lrcorner pa] shifted (stemshiftfrom, -ExHeight/4) ;
> z2 = 0.5[llcorner pb,lrcorner pb] shifted (stemshiftto, -ExHeight/4) ;
> y3 = min(y1,y2) - ExHeight/2 -delta;
> else :
> z1 = 0.5[ulcorner pa,urcorner pa] shifted (stemshiftfrom, ExHeight/4) ;
> z2 = 0.5[ulcorner pb,urcorner pb] shifted (stemshiftto, ExHeight/4) ;
> y3 = max(y1,y2) + ExHeight/2 +delta;
> fi ;
> if na = nb : % Check that positions are on the same page
> pickup pencircle scaled 0.6pt ;
> if product = "sym" :
> draw z1 -- (x1,y3+ExHeight/2) ;
> draw z2 -- (x2,y3+ExHeight/2) ;
> pickup pencircle scaled 1.2pt ;
> draw (x1-EmWidth/8,y3) -- (x2+EmWidth/8,y3) ;
> else :
> pab := z1 -- (x1,y3) -- (x2,y3) -- z2{down} ;
> draw pab ;
> fi ;
> positioninregion ;
> fi ;
> \stopMPpositiongraphic
>
> A connector command might look something like this:
>
> \setMPpositiongraphic{X-1}{mypos:contract}{to=X-2,product=sym,startstem=-2,stopstem=2,distance=0.5ex}
>
> All of the key=value pairs in the last argument of \setMPpositiongraphic pop right up in my MetaPost code with mpvar(“key”). I haven’t been able to follow this with \mathboxanchored and \connectboxanchors. My two questions are:
>
> 1) Can I use \setMPpositiongraphic with \mathboxanchored? That would allow me to go straight to my MetaPost code without the \connectboxanchors interface
>
> 2) Can I tell \connectboxanchors to use my MetaPost code and pass key=value pairs like I do with \setMPpositiongraphic?
see attached ... the 'cross pages' feature is in the upcoming
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
[-- Attachment #2: anchors-002.tex --]
[-- Type: text/plain, Size: 3017 bytes --]
\continuewhenlmtxmode
\usemodule[article-basic]
\starttext
\startboxanchoring[+]
\connectboxanchors[top] [top] [distance=1ex,arrow=no] {c1}{c2}
\connectboxanchors[bottom] [bottom] [distance=1ex,arrow=no] {c2}{c3}
\startformula
\mathboxanchored[nucleus]{c1}{e}_{\alpha}
\mathboxanchored[nucleus]{c2}{e}^{\mu}
\mathboxanchored[nucleus]{c3}{e}_{\dot{\beta}} = \frac{1}{\sqrt{2}}
\sigma_{\alpha,\dot{\beta}}^{\mu}
\stopformula
\stopboxanchoring
\startboxanchoring[+]
\connectboxanchors[top] [top] [distance=1ex,arrow=no] {c1}{c2}
\connectboxanchors[bottom] [bottom] [distance=1ex,arrow=no] {c2}{c3}
\startformula
\mathboxanchored[nucleus]{c1}{e}_{\alpha}
\mathboxanchored[nucleus]{c2}{e}^{\mu}
\mathboxanchored[nucleus]{c3}{e}_{\dot{\beta}} = \frac{1}{\sqrt{2}}
\sigma_{\alpha,\dot{\beta}}^{\mu}
\stopformula
\stopboxanchoring
\startboxanchoring[+]
\connectboxanchors[top] [top] [distance=1ex,arrow=yes,page=yes] {c1}{c2}
\connectboxanchors[bottom] [bottom] [distance=1ex,arrow=yes,page=yes] {c2}{c3}
\startformula
\mathboxanchored[nucleus]{c1}{e}_{\alpha}
\mathboxanchored[nucleus]{c2}{e}^{\mu}
e _{\dot{\beta}} = \frac{1}{\sqrt{2}}
\sigma_{\alpha,\dot{\beta}}^{\mu}
\stopformula
\page
\startformula
e _{\alpha}
e ^{\mu}
\mathboxanchored[nucleus]{c3}{e}_{\dot{\beta}} = \frac{1}{\sqrt{2}}
\sigma_{\alpha,\dot{\beta}}^{\mu}
\stopformula
\stopboxanchoring
\startMPpositiongraphic{mypos:boxanchor:top}
begingroup ;
save f, t, p ; pair f, t ; path p ;
f := positionxy(mpvars("from")) ;
t := positionxy(mpvars("to")) ;
p := f { up } .. t ;
drawarrow p
withpen pencircle scaled mpvard "rulethickness"
withcolor mpvars "linecolor" ; % historically different names
positioninregion ;
endgroup ;
\stopMPpositiongraphic
\startMPpositiongraphic{mypos:boxanchor:bottom}
begingroup ;
save f, t, p ; pair f, t ; path p ;
f := positionxy(mpvars("from")) ;
t := positionxy(mpvars("to")) ;
p := f { down } .. t ;
drawarrow p
withpen pencircle scaled mpvard "rulethickness"
withcolor mpvars "linecolor" ; % historically different names
positioninregion ;
endgroup ;
\stopMPpositiongraphic
\startboxanchoring[+]
\connectboxanchors[top] [top] [distance=1ex,rulethickness=1pt,rulecolor=darkgreen,mp=mypos:boxanchor:top] {c1}{c2}
\connectboxanchors[bottom] [bottom] [distance=1ex,rulethickness=1pt,rulecolor=darkred, mp=mypos:boxanchor:bottom] {c2}{c3}
\startformula
\mathboxanchored[nucleus]{c1}{e}_{\alpha}
\mathboxanchored[nucleus]{c2}{e}^{\mu}
\mathboxanchored[nucleus]{c3}{e}_{\dot{\beta}} = \frac{1}{\sqrt{2}}
\sigma_{\alpha,\dot{\beta}}^{\mu}
\stopformula
\stopboxanchoring
\stoptext
[-- Attachment #3: anchors-002.pdf --]
[-- Type: application/pdf, Size: 10666 bytes --]
[-- Attachment #4: Type: text/plain, Size: 496 bytes --]
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://www.ntg.nl/mailman/listinfo/ntg-context
webpage : https://www.pragma-ade.nl / http://context.aanhet.net
archive : https://bitbucket.org/phg/context-mirror/commits/
wiki : https://contextgarden.net
___________________________________________________________________________________
next prev parent reply other threads:[~2022-12-15 10:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-15 3:20 Gavin via ntg-context
2022-12-15 10:36 ` Hans Hagen via ntg-context [this message]
2022-12-15 16:15 ` Gavin via ntg-context
2022-12-15 17:21 ` Hans Hagen via ntg-context
2022-12-15 21:54 ` Otared Kavian via ntg-context
2022-12-16 16:42 ` Hans Hagen via ntg-context
2022-12-16 16:55 ` Hans Hagen via ntg-context
2022-12-18 11:03 ` Alexandre Christe via ntg-context
2022-12-21 14:05 ` Gavin via ntg-context
2022-12-21 14:29 ` Sans Math fonts, for example Computer Modern Bright Oliver Sieber via ntg-context
2022-12-21 14:41 ` Mikael Sundqvist via ntg-context
2022-12-21 16:00 ` Mathematical MetaFun Mania Hans Hagen via ntg-context
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=8f54f916-907b-12cf-9525-ff4a40665ae2@freedom.nl \
--to=ntg-context@ntg.nl \
--cc=j.hagen@freedom.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).