ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Oliver Buerschaper <oliver.buerschaper@mpq.mpg.de>
To: mailing ConTeXt users list for <ntg-context@ntg.nl>
Cc: Hoekwater Taco <taco@elvenkind.com>
Subject: Re: Passing info from MetaPost to TeX
Date: Sun, 1 Aug 2010 12:16:45 +0200	[thread overview]
Message-ID: <38DD56B8-F7E1-47EE-8C41-4146D4BBD780@mpq.mpg.de> (raw)
In-Reply-To: <4C527966.3030504@elvenkind.com>

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
___________________________________________________________________________________


  reply	other threads:[~2010-08-01 10:16 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-20 12:00 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 [this message]
2010-08-01 10:42           ` Taco Hoekwater
2010-08-01 10:52           ` Oliver Buerschaper

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=38DD56B8-F7E1-47EE-8C41-4146D4BBD780@mpq.mpg.de \
    --to=oliver.buerschaper@mpq.mpg.de \
    --cc=ntg-context@ntg.nl \
    --cc=taco@elvenkind.com \
    /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).