ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Passing info from MetaPost to TeX
@ 2010-07-20 12:00 Oliver Buerschaper
  2010-07-22 20:22 ` Hans Hagen
  0 siblings, 1 reply; 8+ messages in thread
From: Oliver Buerschaper @ 2010-07-20 12:00 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


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

* Re: Passing info from MetaPost to TeX
  2010-07-20 12:00 Passing info from MetaPost to TeX Oliver Buerschaper
@ 2010-07-22 20:22 ` Hans Hagen
  2010-07-24 18:35   ` Oliver Buerschaper
  0 siblings, 1 reply; 8+ messages in thread
From: Hans Hagen @ 2010-07-22 20:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


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

* Re: Passing info from MetaPost to TeX
  2010-07-22 20:22 ` Hans Hagen
@ 2010-07-24 18:35   ` Oliver Buerschaper
  2010-07-30  6:20     ` Oliver Buerschaper
  0 siblings, 1 reply; 8+ messages in thread
From: Oliver Buerschaper @ 2010-07-24 18:35 UTC (permalink / raw)
  To: Hans Hagen

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


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

* Re: Passing info from MetaPost to TeX
  2010-07-24 18:35   ` Oliver Buerschaper
@ 2010-07-30  6:20     ` Oliver Buerschaper
  2010-07-30  7:04       ` Taco Hoekwater
  0 siblings, 1 reply; 8+ messages in thread
From: Oliver Buerschaper @ 2010-07-30  6:20 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


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

* Re: Passing info from MetaPost to TeX
  2010-07-30  6:20     ` Oliver Buerschaper
@ 2010-07-30  7:04       ` Taco Hoekwater
  2010-08-01 10:16         ` Oliver Buerschaper
  0 siblings, 1 reply; 8+ messages in thread
From: Taco Hoekwater @ 2010-07-30  7:04 UTC (permalink / raw)
  To: mailing list for ConTeXt users

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
___________________________________________________________________________________


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

* Re: Passing info from MetaPost to TeX
  2010-07-30  7:04       ` Taco Hoekwater
@ 2010-08-01 10:16         ` Oliver Buerschaper
  2010-08-01 10:42           ` Taco Hoekwater
  2010-08-01 10:52           ` Oliver Buerschaper
  0 siblings, 2 replies; 8+ messages in thread
From: Oliver Buerschaper @ 2010-08-01 10:16 UTC (permalink / raw)
  To: mailing ConTeXt users list for; +Cc: Hoekwater Taco

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

I'm asking...


> 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


... because adjusting the bounding box fails once the figure grows a bit larger. Just use

u := 3StrutHeight;

in the code above and you'll see the effect.

Thanks for your help,
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
___________________________________________________________________________________


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

* Re: Passing info from MetaPost to TeX
  2010-08-01 10:16         ` Oliver Buerschaper
@ 2010-08-01 10:42           ` Taco Hoekwater
  2010-08-01 10:52           ` Oliver Buerschaper
  1 sibling, 0 replies; 8+ messages in thread
From: Taco Hoekwater @ 2010-08-01 10:42 UTC (permalink / raw)
  To: Oliver Buerschaper; +Cc: mailing ConTeXt users list for

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
___________________________________________________________________________________


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

* Re: Passing info from MetaPost to TeX
  2010-08-01 10:16         ` Oliver Buerschaper
  2010-08-01 10:42           ` Taco Hoekwater
@ 2010-08-01 10:52           ` Oliver Buerschaper
  1 sibling, 0 replies; 8+ messages in thread
From: Oliver Buerschaper @ 2010-08-01 10:52 UTC (permalink / raw)
  To: mailing list for ConTeXt users

> ... because adjusting the bounding box fails once the figure grows a bit larger. Just use
> 
> u := 3StrutHeight;
> 
> in the code above and you'll see the effect.

I forgot to say you need to add some text above and below the displayed formula... then you'll see some awkward vertical spacing :-(

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
___________________________________________________________________________________


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

end of thread, other threads:[~2010-08-01 10:52 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-20 12:00 Passing info from MetaPost to TeX Oliver Buerschaper
2010-07-22 20:22 ` Hans Hagen
2010-07-24 18:35   ` Oliver Buerschaper
2010-07-30  6:20     ` Oliver Buerschaper
2010-07-30  7:04       ` Taco Hoekwater
2010-08-01 10:16         ` Oliver Buerschaper
2010-08-01 10:42           ` Taco Hoekwater
2010-08-01 10:52           ` Oliver Buerschaper

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