ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* MetaPost graphics within formulas
@ 2008-07-25 16:32 Oliver Buerschaper
  2008-07-25 17:53 ` Peter Rolf
  2008-07-26 12:18 ` Peter Münster
  0 siblings, 2 replies; 5+ messages in thread
From: Oliver Buerschaper @ 2008-07-25 16:32 UTC (permalink / raw)
  To: mailing ConTeXt users list for

Hi there,

maths can sometimes be weird and even more so the kinds of formulas  
one needs to typeset occasionally ;-)

So here I need to typeset triangles and a variety of other polygons  
right in the middle of a display formula. What I've been able to come  
up with so far is something like this:

---
\starttext


\startuseMPgraphic{tetrahedral}
	u := 10pt;
	draw (0,0)--(2u,0)--(u,sqrt(3)*u)--cycle;
\stopuseMPgraphic

\startformula
\Phi(\useMPgraphic{tetrahedral})=F_{kln}^{ijm}\,v_iv_jv_kv_l\, 
\delta_{j^*nk^*}\,\delta_{l^*n^*i^*}\,\Phi(\emptyset)
\stopformula


\stoptext
---

Now if I only knew how to properly align my MetaPost figure with the  
rest of the formula … any ideas?

Cheerio,
Oliver
___________________________________________________________________________________
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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: MetaPost graphics within formulas
  2008-07-25 16:32 MetaPost graphics within formulas Oliver Buerschaper
@ 2008-07-25 17:53 ` Peter Rolf
  2008-07-26  8:47   ` Oliver Buerschaper
  2008-07-26 12:18 ` Peter Münster
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Rolf @ 2008-07-25 17:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Oliver Buerschaper schrieb:
> Hi there,
> 
> maths can sometimes be weird and even more so the kinds of formulas  
> one needs to typeset occasionally ;-)
> 
> So here I need to typeset triangles and a variety of other polygons  
> right in the middle of a display formula. What I've been able to come  
> up with so far is something like this:
> 
> ---
> \starttext
> 
> 
> \startuseMPgraphic{tetrahedral}
> 	u := 10pt;
> 	draw (0,0)--(2u,0)--(u,sqrt(3)*u)--cycle;
> \stopuseMPgraphic
>
The bounding box of the graphic is set on the base line. So you have to 
add some artificial depth to the graphic.


\starttext

\startreusableMPgraphic{tetrahedral}
         begingroup
	u := 10pt;
	draw (0,0)--(2u,0)--(u,sqrt(3)*u)--cycle;
         draw boundingbox currentpicture withpen pensquare scaled .1;
         endgroup;
\stopreusableMPgraphic

\def\Tetrahedral{\lower5pt\hbox{\reuseMPgraphic{tetrahedral}}}% needs 
some fiddling :)

\startformula
\Phi(\Tetrahedral)=F_{kln}^{ijm}\,v_iv_jv_kv_l\,
\delta_{j^*nk^*}\,\delta_{l^*n^*i^*}\,\Phi(\emptyset)
\stopformula

\stoptext


Best wishes, Peter

> \startformula
> \Phi(\useMPgraphic{tetrahedral})=F_{kln}^{ijm}\,v_iv_jv_kv_l\, 
> \delta_{j^*nk^*}\,\delta_{l^*n^*i^*}\,\Phi(\emptyset)
> \stopformula
> 
> 
> \stoptext
> ---
> 
> Now if I only knew how to properly align my MetaPost figure with the  
> rest of the formula … any ideas?
> 
> Cheerio,
> Oliver
> ___________________________________________________________________________________
> 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://tex.aanhet.net
> archive  : https://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 

___________________________________________________________________________________
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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: MetaPost graphics within formulas
  2008-07-25 17:53 ` Peter Rolf
@ 2008-07-26  8:47   ` Oliver Buerschaper
  2008-07-26 10:09     ` Peter Rolf
  0 siblings, 1 reply; 5+ messages in thread
From: Oliver Buerschaper @ 2008-07-26  8:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users

> The bounding box of the graphic is set on the base line. So you have  
> to
> add some artificial depth to the graphic.
>
>
> \starttext
>
> \startreusableMPgraphic{tetrahedral}
>         begingroup
> 	u := 10pt;
> 	draw (0,0)--(2u,0)--(u,sqrt(3)*u)--cycle;
>         draw boundingbox currentpicture withpen pensquare scaled .1;
>         endgroup;
> \stopreusableMPgraphic
>
> \def\Tetrahedral{\lower5pt\hbox{\reuseMPgraphic{tetrahedral}}}% needs
> some fiddling :)
>
> \startformula
> \Phi(\Tetrahedral)=F_{kln}^{ijm}\,v_iv_jv_kv_l\,
> \delta_{j^*nk^*}\,\delta_{l^*n^*i^*}\,\Phi(\emptyset)
> \stopformula
>
> \stoptext

That's exactly what I was looking for … thanks very much!

Out of curiosity just a few questions … why do you use grouping in the  
MetaPost code and why do you draw the bounding box explicitly? When I  
was experimenting with your suggestion a bit I tried leaving out those  
two commands at some point and surprisingly things still looked fine …  
And what's the difference between \startreusableMPgraphic and  
\startuseMPgraphic? Does caching play a role?

Thanks again,
Oliver
___________________________________________________________________________________
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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: MetaPost graphics within formulas
  2008-07-26  8:47   ` Oliver Buerschaper
@ 2008-07-26 10:09     ` Peter Rolf
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Rolf @ 2008-07-26 10:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Oliver Buerschaper schrieb:
>> The bounding box of the graphic is set on the base line. So you have  
>> to
>> add some artificial depth to the graphic.
>>
>>
>> \starttext
>>
>> \startreusableMPgraphic{tetrahedral}
>>         begingroup

	save u;

>> 	u := 10pt;
>> 	draw (0,0)--(2u,0)--(u,sqrt(3)*u)--cycle;
>>         draw boundingbox currentpicture withpen pensquare scaled .1;
>>         endgroup;
>> \stopreusableMPgraphic
>>
>> \def\Tetrahedral{\lower5pt\hbox{\reuseMPgraphic{tetrahedral}}}% needs
>> some fiddling :)
>>
>> \startformula
>> \Phi(\Tetrahedral)=F_{kln}^{ijm}\,v_iv_jv_kv_l\,
>> \delta_{j^*nk^*}\,\delta_{l^*n^*i^*}\,\Phi(\emptyset)
>> \stopformula
>>
>> \stoptext
> 
> That's exactly what I was looking for … thanks very much!
> 
> Out of curiosity just a few questions … why do you use grouping in the  
> MetaPost code and why do you draw the bounding box explicitly? When I  
> was experimenting with your suggestion a bit I tried leaving out those  
> two commands at some point and surprisingly things still looked fine …  
> And what's the difference between \startreusableMPgraphic and  
> \startuseMPgraphic? Does caching play a role?
>

I do grouping just by habit (btw: a 'save u;' is missing). Without 
grouping your variables simply overwrite prior defined ones. With 
grouping all saved(!) variables are restored after endgroup (attention: 
don't ever forget the simicolon after endgroup). And you are right, 
grouping is not really needed in a simple context.

Coming to the bounding box; it's just for debugging. My first try was to 
'reduce' the height of the bounding box (all stuff beneath the base line 
is then drawn outside the final bounding box). But when I thought about 
subscript this was no longer an option. Anyhow, here is the code:

\startreusableMPgraphic{tetrahedral}
         begingroup
         save bb,d,u;

	u := 10pt;
	draw ((0,0)--(2u,0)--(u,sqrt(3)*u)--cycle) ;

         d := 0.25u; % depth
         path bb; bb:= boundingbox currentpicture;
         setbounds currentpicture to unitsquare
         xyscaled(xpart point 2 of bb,ypart point 2 of bb -d)
         yshifted d;
         draw boundingbox currentpicture withpen pensquare scaled .1;
         endgroup;
\stopreusableMPgraphic

3-------2
|       |  bounding box
|       |  and it's points
0-------1

The extreme points of the complete graphic determine the size of the 
bounding box. The relative position of the complete graphic (where it is 
drawn) has no influence on that. This is why a single fullcircle gives 
you the same graphic as a single unitcircle.

All your questions about the different graphic types are aswered in the 
'Metafun' manual, 'Integrated graphics' on pages 111-114.

Best wishes, Peter

> Thanks again,
> Oliver
> ___________________________________________________________________________________
> 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://tex.aanhet.net
> archive  : https://foundry.supelec.fr/projects/contextrev/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 

___________________________________________________________________________________
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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: MetaPost graphics within formulas
  2008-07-25 16:32 MetaPost graphics within formulas Oliver Buerschaper
  2008-07-25 17:53 ` Peter Rolf
@ 2008-07-26 12:18 ` Peter Münster
  1 sibling, 0 replies; 5+ messages in thread
From: Peter Münster @ 2008-07-26 12:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On Fri, Jul 25 2008, Oliver Buerschaper wrote:

> \Phi(\useMPgraphic{tetrahedral})=F_{kln}^{ijm}\,v_iv_jv_kv_l\,
> [...]
> Now if I only knew how to properly align my MetaPost figure with the  
> rest of the formula … any ideas?

\Phi\left(\vcenter{\useMPgraphic{tetrahedral}}\right)= ...

Cheers, Peter

-- 
http://pmrb.free.fr/contact/

___________________________________________________________________________________
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://tex.aanhet.net
archive  : https://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2008-07-26 12:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-25 16:32 MetaPost graphics within formulas Oliver Buerschaper
2008-07-25 17:53 ` Peter Rolf
2008-07-26  8:47   ` Oliver Buerschaper
2008-07-26 10:09     ` Peter Rolf
2008-07-26 12:18 ` Peter Münster

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