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

Michaël Cadilhac michael at cadilhac.name
Wed Sep 19 15:13:46 CEST 2007


"Mojca Miklavec" <mojca.miklavec.lists at gmail.com> writes:

> On 9/18/07, Michaël Cadilhac wrote:
>> "Mojca Miklavec" writes:
>>
>> > Can you try to compile the following document with "texexec yourfile.tex"?
>
> Oh, I'm sorry. It should have been
>
> \starttext
> % MPpage, not MPcode
> \startMPpage
>    label(\sometxt{b}, (2c,2cm));
>    label(\sometxt{def\vulgarfraction{1}{2}}, (4cm,4cm));
>    label(\sometxt{abc}, (0,0)); % if textext() doesn't work
> \stopMPpage
> \stoptext

>> Sure!  I'm not really sure what you're trying to make me understand, but
>> well, texexec --mptex of this file gives a drawing with the `b' and
>> where `def' and `abc' should be, the text `unknown'.
>
> Why the switch --mptex?

Well, without it, it pukes me something like:

------------------------------------------------------------------------
! Undefined control sequence.
<argument> label(\sometxt 
                          {b}, (2cm,2cm))
\nonowriteMPgraphicline ... \long \edef \ascii {#1
                                                  }\expandafter \flushMPgrap...

\shortMPflushN ...nowriteMPgraphicline #1#2\MPend 
                                                  \expandafter \shortMPflush...
<argument> label(\sometxt {b}, (2cm,2cm));
                                           label(\sometxt {def\vulgarfractio...

\writeMPgraphicshortN ... \space \shortMPflushN #1
                                                  \empty ;\relax ;\egroup 
\startMPgraphic ...hic \writecheckedMPgraphic {#1}
                                                  \stopwritingMPgraphic 
...
l.7 \stopMPpage
------------------------------------------------------------------------

Whereas with it, well...  With your new modifications, I don't have any
output, so I suppose something's wrong, somewhere.

Heck...  If I try with the old version, I don't have any output now
either.

> I thought that you wanted to use variable text inside labels.
> Otherwise you can always use \sometxt{...}.

I'm dreadfully sorry, I would love to understand the ins and outs of
MetaPost, but I'm just not at this stage.  The very thing I want to do
is something like that :

for i := 1 upto 2:
  beginfig(i)
    string phantom;
    phantom := if i = 1: "\phantom" else: "" fi;
    label (TEX("This is a " & phantom & "{funny} thing"));
  endfig;
endfor;

That is to say, enable some part of TeX text according to the picture
number (as you can imagine, it's for a presentation).  I hope we've not
misunderstand this.

> You can include the resulting PDF to the .tex file.

Okey, so texexec is supposed to give me a PDF, this is cool :-)  I heard
about CONTeXT only some weeks ago, and I just see that MetaFun is to
CONTeXT what pstricks or pgf is to LaTeX (right ?).

>> Are you suggesting that I should use another way of using MetaPost?
>
> Well, this way of creating metapost graphics is just one way to avoid
> the need to write this lengthy portion of code at the top of every
> metapost graphic:

Is it? :-)  Well, I should be able to test a bit once I can get texexec
to work correctly.

> As a summary: the approach I have shown simplifies the usage of TeX
> labels inside metapost graphics a bit, nothing more. You can use
> exactly the same metapost code as you would inside a .mp file, with
> the only exception that there's no need for verbatimtex and TEX()
> trickery. Nothing else but that.

This is pure gold. :-)  Thanks !

And BTW, you're giving time to help me with this, so I want to give you
some of my time in return :-) Question is, as I'm an Emacs developer, do
you need any fix/fanciness on the Meta* mode of Emacs ?

-- 
 |   Michaël `Micha' Cadilhac       |  Isn't vi that text editor with        |
 |   http://michael.cadilhac.name   |   two modes... One that beeps and      |
 |   JID/MSN:                       |     one that corrupts your file?       |
 `----  michael.cadilhac at gmail.com  |           -- Dan Jacobson         -  --'
-------------- 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/20070919/cad04d2b/attachment.bin 


More information about the metapost mailing list