[metapost] Bug in MetaPost

Ariel Barton barto106 at math.umn.edu
Sun Dec 15 16:24:37 CET 2013


I've been poking at this particular bug too. It seems to be a problem with
MetaPost's low-level "put a string on the figure" routine; you don't even
need btex/etex.

Example:

beginfig(0);
    string test;
    test = "ABC" & char0 & "XYZ";
    label(test,(0,0));
endfig;
end

This will print not "ABC\Gamma XYZ", but "ABC\Gamma\Gamma\Gamma\Gamma". If
the zeroth character in a font shows up in a string, the following
characters in that string are all converted to the same character.

The main zeroth characters to worry about in practice are $-$ (minus),
$\Gamma$ and $\big($.

This is why "$-\infty$" comes out as "--".

The "$-\,\infty$" comes out correctly because the kern (the \,) separates
the $-$ and the $\infty$, so PostScript has to treat them as two separate
strings. Similarly, a $-3$ would come out correctly because the $-$ and the
$3$ are from different fonts, and so PostScript has to treat them as two
separate strings.

If you need a $\Gamma$ or $\big($, you can get the correct behavior with a
${\Gamma\mkern0.01mu}$. You have to be a little careful with the $-$ to get
the spacing after it right. (Various TeX-internal workarounds, like
$\Gamma\null$ or $\Gamma\,\!$, don't work; you need a nonzero amount of
space to avoid this low-level bug.)



On Sun, Dec 15, 2013 at 5:30 AM, Pétiard François
<petiard.francois at free.fr>wrote:

> Hello!
>
> I've already written that (2012/03/24), but there is no change...
>
> I'm on Windows 7, MiKTeX 2.9 (64 bits), MetaPost 1.803.
>
> Here is my file test.mp:
>
> %%%%%%%%%%%%%%%%%%%%%%%%%%
> prologues:=3;
> outputtemplate:="%j.eps";
> beginfig(0)
> label(btex $-\infty$ etex,(0,20));%%%%%%% 1
> label(btex $\null-\infty$ etex,(0,0));%%% 2
> label(btex $-\!\infty$ etex,(0,-20));%%%% 3
> label(btex $-\,\infty$ etex,(0,-40));%%%% 4
> label(btex $-\,\!\infty$ etex,(0,-60));%% 5
> label(btex $+\infty$ etex,(0,-80));%%%%%% 6
> endfig;
> end;
> %%%%%%%%%%%%%%%%%%%%%%%%%
>
> When I make:
>
> mpost -debug test.mp
>
> I obtain a curious file test.eps (see the labels 1 and 5).
>
> Is there a chance to see that bug repaired ?
>
> Cheers
>
> François
>
>
>
> --
> francois.petiard at univ-fcomte.fr
>
> --
> http://tug.org/metapost/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://tug.org/pipermail/metapost/attachments/20131215/e16da4c1/attachment.html>


More information about the metapost mailing list