ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Metapost and TeX [OT]
@ 2004-08-24  2:48 skhilji
  2004-08-24  3:02 ` Metapost and TeX Matthias Weber
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: skhilji @ 2004-08-24  2:48 UTC (permalink / raw)


I don't have any experience in metapost.  I would appreciate if someone would please answer this question without me having to do thru tutorials and metapost source code.

I was wondering how does metapost talk to TeX?  Quicky glancing through the metafun book, I found out that you can super-impose text typeset by TeX on top of a diagram.  I imagine you could do the same with mathematical equations too.

So how does metapost interact with TeX?  Let me guess:

1)  Metapost could first write down to a file the text that it wan't TeX to typeset.  It could then run TeX on the file.  TeX produces a DVI file and metapost reads it back.  It can then superimpose it on top of a picture.

2)  Metapost could also be including within itself a simplified version of TeX.  But that would be reinventing the wheel.

So how does it happen in reality?

The reason that I am asking is that I am interested in producing some diagrams using the libHARU PDF library (a C++ library to produce PDF files).  Beautiful Text support, however, is missing from the library.  I was wondering if I could hack it up so that I could somehow use TeX for the text part and C++ calls for the graphics part.

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

* Re: Metapost and TeX
  2004-08-24  2:48 Metapost and TeX [OT] skhilji
@ 2004-08-24  3:02 ` Matthias Weber
  2004-08-24  6:08 ` Metapost and TeX [OT] Brooks Moses
  2004-08-24  6:14 ` Taco Hoekwater
  2 siblings, 0 replies; 6+ messages in thread
From: Matthias Weber @ 2004-08-24  3:02 UTC (permalink / raw)


This is not exactly an answer to your question, but it might
solve your problem.

You can use overlays with any figure, see cont-eni.pdf page 150ff.

The mechanism is not so much the tex-engine TeX but one of the many 
little
add-ons that come with ConText and exploit features of PDF.

In particular, you can use your PDFs directly in ConText.
I found this easier than to teach my picture producing applications to 
use the
right fonts in the right way at the right place.

Matthias


On Aug 23, 2004, at 9:48 PM, skhilji@tampabay.rr.com wrote:

> I don't have any experience in metapost.  I would appreciate if 
> someone would please answer this question without me having to do thru 
> tutorials and metapost source code.
>
> I was wondering how does metapost talk to TeX?  Quicky glancing 
> through the metafun book, I found out that you can super-impose text 
> typeset by TeX on top of a diagram.  I imagine you could do the same 
> with mathematical equations too.
>
> So how does metapost interact with TeX?  Let me guess:
>
> 1)  Metapost could first write down to a file the text that it wan't 
> TeX to typeset.  It could then run TeX on the file.  TeX produces a 
> DVI file and metapost reads it back.  It can then superimpose it on 
> top of a picture.
>
> 2)  Metapost could also be including within itself a simplified 
> version of TeX.  But that would be reinventing the wheel.
>
> So how does it happen in reality?
>
> The reason that I am asking is that I am interested in producing some 
> diagrams using the libHARU PDF library (a C++ library to produce PDF 
> files).  Beautiful Text support, however, is missing from the library. 
>  I was wondering if I could hack it up so that I could somehow use TeX 
> for the text part and C++ calls for the graphics part.
>
>
> _______________________________________________
> ntg-context mailing list
> ntg-context@ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
>
>

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

* Re: Metapost and TeX [OT]
  2004-08-24  2:48 Metapost and TeX [OT] skhilji
  2004-08-24  3:02 ` Metapost and TeX Matthias Weber
@ 2004-08-24  6:08 ` Brooks Moses
  2004-08-24  8:18   ` Hans Hagen
  2004-08-24  6:14 ` Taco Hoekwater
  2 siblings, 1 reply; 6+ messages in thread
From: Brooks Moses @ 2004-08-24  6:08 UTC (permalink / raw)


On Mon, Aug 23, 2004 at 10:48:42PM -0400, skhilji@tampabay.rr.com wrote:
> I don't have any experience in metapost.  I would appreciate if someone would
> please answer this question without me having to do thru tutorials and
> metapost source code.
> 
> I was wondering how does metapost talk to TeX?  Quicky glancing through the
> metafun book, I found out that you can super-impose text typeset by
> TeX on top of a diagram.  I imagine you could do the same with
> mathematical equations too.

The following is as I understand it; others can I'm sure correct any
misunderstandings:

Metapost dumps out a TeX file, consisting of any header commands
specified in the Metapost file, and whatever is between btex and etex
tags.  It also puts in stuff so that what's between each pair of tags
gets put on its own page.  (This is actually done with the mpto command,
rather than in Metapost itself; if you just run that, you can examine
the output to see what TeX commands it uses.)

TeX is then run on this file, creating a .dvi file.

Metapost then reads in the .dvi file, using that to create the typeset
text that appears in the output Postscript file.

- Brooks

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

* Re: Metapost and TeX [OT]
  2004-08-24  2:48 Metapost and TeX [OT] skhilji
  2004-08-24  3:02 ` Metapost and TeX Matthias Weber
  2004-08-24  6:08 ` Metapost and TeX [OT] Brooks Moses
@ 2004-08-24  6:14 ` Taco Hoekwater
  2004-08-24  8:21   ` Hans Hagen
  2 siblings, 1 reply; 6+ messages in thread
From: Taco Hoekwater @ 2004-08-24  6:14 UTC (permalink / raw)




skhilji@tampabay.rr.com wrote:

> So how does it happen in reality?

Matthias' reply is better for your situation, but for curiosity's
sake, here is what actually happens:

- MetaPost is happily reading MetaPost commands when suddenly it sees
  a "btex" command.

- Now it will throw away everything upto the next "etex", and it will
  run the external command "makempx" with the current filename as argument.
  
* makempx's goal is to create a file with the same name as it's argument, but
  with the extension replaced with ".mpx". That file will contain a series of
  low-level MetaPost commands for each label in the source file, and 
  those lists of commands are separated by the MetaPost command "mpxbreak".

* nothing is done by makempx if the mpx file exists and is newer than the  
  source file.

** otherwise, the source file is scanned for verbatimtex ... etex and btex ... etex
   blocks. These are wrapped in very simple TeX macros and written to a TeX input
   file.

** TeX is run, to produce a DVI file from these commands (each dvi page representing 
   a label)

** The entire DVI file is then converted into the ".mpx" file in a single action.

- MetaPost will now open the ".mpx" file as a concurrent source of commands
  linked to the current source file, and read commands from it up to the
  first "mpxbreak".

- The location pointer in the ".mpx" file is saved for subsequent labels.

Greetings, Taco

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

* Re: Metapost and TeX [OT]
  2004-08-24  6:08 ` Metapost and TeX [OT] Brooks Moses
@ 2004-08-24  8:18   ` Hans Hagen
  0 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2004-08-24  8:18 UTC (permalink / raw)


Brooks Moses wrote:

>On Mon, Aug 23, 2004 at 10:48:42PM -0400, skhilji@tampabay.rr.com wrote:
>  
>
>>I don't have any experience in metapost.  I would appreciate if someone would
>>please answer this question without me having to do thru tutorials and
>>metapost source code.
>>
>>I was wondering how does metapost talk to TeX?  Quicky glancing through the
>>metafun book, I found out that you can super-impose text typeset by
>>TeX on top of a diagram.  I imagine you could do the same with
>>mathematical equations too.
>>    
>>
>
>The following is as I understand it; others can I'm sure correct any
>misunderstandings:
>
>Metapost dumps out a TeX file, consisting of any header commands
>specified in the Metapost file, and whatever is between btex and etex
>tags.  It also puts in stuff so that what's between each pair of tags
>gets put on its own page.  (This is actually done with the mpto command,
>rather than in Metapost itself; if you just run that, you can examine
>the output to see what TeX commands it uses.)
>
>TeX is then run on this file, creating a .dvi file.
>
>Metapost then reads in the .dvi file, using that to create the typeset
>text that appears in the output Postscript file.
>  
>
you miss a step: a mpx file is created from the dvi file; an mpx file is a bunch of metapost pictures that will replace the btex..etex's in the mp file 

Hans 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

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

* Re: Metapost and TeX [OT]
  2004-08-24  6:14 ` Taco Hoekwater
@ 2004-08-24  8:21   ` Hans Hagen
  0 siblings, 0 replies; 6+ messages in thread
From: Hans Hagen @ 2004-08-24  8:21 UTC (permalink / raw)


Taco Hoekwater wrote:

>- The location pointer in the ".mpx" file is saved for subsequent labels.
>  
>
a small addition: 

- since we are dealing with parsing, btex .. etex cannot be changed dynamically, which is one of the reasons why metafun has the textext macro which provides an alternative for btex .. etex 

Hans 


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

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

end of thread, other threads:[~2004-08-24  8:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-08-24  2:48 Metapost and TeX [OT] skhilji
2004-08-24  3:02 ` Metapost and TeX Matthias Weber
2004-08-24  6:08 ` Metapost and TeX [OT] Brooks Moses
2004-08-24  8:18   ` Hans Hagen
2004-08-24  6:14 ` Taco Hoekwater
2004-08-24  8:21   ` Hans Hagen

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