Re: [NTG-context] Passing info from MetaPost to TeX

2010-08-01 Thread Taco Hoekwater

On 08/01/2010 12:16 PM, Oliver Buerschaper wrote:

Hi Taco,


Well, you could create a temporary file from withing the metapost
graphic, then read that file back on the TeX side, and then shift
the image vertically based on the info from that.


Could you give me a hint on how to parse such an auxiliary file in
TeX? I've never done any sort of that programming before...


You don't have to worry about parsing, just write something like
this in the metapost code:

write \string\def\string\MathAxis{ decimal (sqrt(3)*u/3) } to 
info.tex;


Then \input info.

Best wishes,
Taco
___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Passing info from MetaPost to TeX

2010-07-30 Thread Oliver Buerschaper
No answer :-( Does that mean it's impossible with current technology?

Oliver



 is it possible to pass data from MetaPost back to TeX? This would be 
 similar in spirit to, say, the MetaPost variable BodyFontSize that contains 
 data from the TeX surrounding. Just the other way round.
 
 maybe future mlib versions will provide something like that (writing 
 something from mp to a lua table); currently you have to use a file or 
 interpret the log (use show to print out values).
 
 OK. What I have in mind is to vertically align a diagram with the math 
 axis... something like:
 
 ---
 \startuseMPgraphic{diagram}
   u := StrutHeight;
   draw origin--(2u,0)--(u,sqrt(3)*u)--cycle;
   % MathAxis at y-coordinate sqrt(3)*u/3
 \stopuseMPgraphic
 
 
 \starttext
 
 \startformula
   A\useMPgraphic{diagram}
   =B
 \stopformula
 
 \stoptext
 ---
 
 It would be great if the comment could be turned into a processing 
 instruction for ConTeXt such that the triangle's center of mass ends up on 
 the math axis of the formula.
 
 What's the best way to achieve this?
 
 Many thanks,
 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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Passing info from MetaPost to TeX

2010-07-30 Thread Taco Hoekwater

On 07/30/2010 08:20 AM, Oliver Buerschaper wrote:

No answer :-( Does that mean it's impossible with current technology?


Well, you could create a temporary file from withing the metapost
graphic, then read that file back on the TeX side, and then shift
the image vertically based on the info from that.

Complicated and a bit ugly, but doable. A nicer solution is to
adjust the bounging box of the image itself so that it does the
right thing. This seems to do the trick (but I recall there is
a way to pass a TeX variable to the figure; and that would be much
cleaner; but I don't remember how offhand).


\startuseMPgraphic{diagram2}
   u := StrutHeight;
   draw origin--(2u,0)--(u,sqrt(3)*u)--cycle;
   currentpicture := currentpicture shifted (0,-(sqrt(3)*u/3));
   setbounds currentpicture to (origin--(2u,0)--(u,sqrt(3)*u)--cycle);
\stopuseMPgraphic

\starttext

\startformula
  A\raise\Umathaxis\displaystyle\hbox{\useMPgraphic{diagram2}}
  =B
\stopformula

\stoptext

___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Passing info from MetaPost to TeX

2010-07-24 Thread Oliver Buerschaper
 is it possible to pass data from MetaPost back to TeX? This would be similar 
 in spirit to, say, the MetaPost variable BodyFontSize that contains data 
 from the TeX surrounding. Just the other way round.
 
 maybe future mlib versions will provide something like that (writing 
 something from mp to a lua table); currently you have to use a file or 
 interpret the log (use show to print out values).

OK. What I have in mind is to vertically align a diagram with the math axis... 
something like:

---
\startuseMPgraphic{diagram}
   u := StrutHeight;
   draw origin--(2u,0)--(u,sqrt(3)*u)--cycle;
   % MathAxis at y-coordinate sqrt(3)*u/3
\stopuseMPgraphic


\starttext

\startformula
   A\useMPgraphic{diagram}
   =B
\stopformula

\stoptext
---

It would be great if the comment could be turned into a processing instruction 
for ConTeXt such that the triangle's center of mass ends up on the math axis of 
the formula.

What's the best way to achieve this?

Many thanks,
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


Re: [NTG-context] Passing info from MetaPost to TeX

2010-07-22 Thread Hans Hagen

On 20-7-2010 2:00, Oliver Buerschaper wrote:

Dear all,

is it possible to pass data from MetaPost back to TeX? This would be similar in 
spirit to, say, the MetaPost variable BodyFontSize that contains data from the 
TeX surrounding. Just the other way round.


maybe future mlib versions will provide something like that (writing 
something from mp to a lua table); currently you have to use a file or 
interpret the log (use show to print out values).


Hans


-
  Hans Hagen | PRAGMA ADE
  Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
 | www.pragma-pod.nl
-
___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___


[NTG-context] Passing info from MetaPost to TeX

2010-07-20 Thread Oliver Buerschaper
Dear all,

is it possible to pass data from MetaPost back to TeX? This would be similar in 
spirit to, say, the MetaPost variable BodyFontSize that contains data from the 
TeX surrounding. Just the other way round.

Best,
Oliver Buerschaper
___
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  : http://foundry.supelec.fr/projects/contextrev/
wiki : http://contextgarden.net
___