[metapost] Can't get write/scantokens to work.

Michaël Cadilhac michael at cadilhac.name
Tue Sep 18 12:24:50 CEST 2007


Hi list!

I'm still pretty much of a newbie in mpost, but I keep learning ; the
new power feature I'm striving to get work is a way to use variables in
a btex...etex construct.

It has been proposed
(http://tex.loria.fr/prod-graph/zoonekynd/metapost/macros.mp) to use the
following macro :

vardef TEX primary s =
  write "verbatimtex"                    to "mptextmp.mp";
  write "\documentclass[12pt]{article}"  to "mptextmp.mp";
  write "\usepackage[T1]{fontenc}"       to "mptextmp.mp";
  write "\usepackage{amsmath,amssymb}"   to "mptextmp.mp";
  write "\begin{document}"               to "mptextmp.mp";
  write "etex"                           to "mptextmp.mp";
  write "btex "&s&" etex"                to "mptextmp.mp";
  write EOF                              to "mptextmp.mp";
  scantokens "input mptextmp"
enddef;

Then use TEX(...) to get a picture of a TeX command.

Well, I don't really understand why all the prologue is required (maybe
because I don't understand the way the input is processed by
scantokens), still, this looks like an ugly hack.

But my very problem is that I can't get it to work.  See the following
file :

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test.mp
Url: http://tug.org/pipermail/metapost/attachments/20070918/773c4ac0/attachment.pl 
-------------- next part --------------

mptopdf(1) just says there's an error (thanks buddy), but mpost(1) seems
just fine about it.  If I run mptopdf(1) after mpost(1), the `b'
disappears and only `1/2' is shown on both upper-right and lower-left
corners.  The point is that I must use mptopdf(1) to get some
transparency effects.

So, question is, am I searching for a feature beyond MP capacities?

Thanks in advance !

-- 
 |   Michaël `Micha' Cadilhac       |  Une erreur peut devenir exacte        |
 |   http://michael.cadilhac.name   |     selon que celui qui l'a commise    |
 |   JID/MSN:                       |  s'est trompé ou non.                  |
 `----  michael.cadilhac at gmail.com  |          -- Pierre Dac            -  --'
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 188 bytes
Desc: not available
Url : http://tug.org/pipermail/metapost/attachments/20070918/773c4ac0/attachment.bin 


More information about the metapost mailing list