The recent update seems to have broken metapost. Anyone else having problems? The following is a MWE taken from the document that used to compile. Thanks for any help.

%% use option 'nowrite' if graphics are stable
%% ---------------------------------------------------------------

numeric v, u, xmin, xmax, ymin, ymax;
numeric ix, iy, tx, ty;
numeric ahlen, ahpos;
numeric gridwidth, axeswidth;
picture xl[], yl[];
ix=1; iy=1;
tx=1; ty=1;
xmin=tx*(-6)/ix; xmax=tx*(6)/ix;
ymin=ty*(-6)/iy; ymax=ty*(6)/iy;
gridwidth:=0.46; axeswidth:=4*gridwidth;
% default arrowhead length is 4pt, compensate for scaling by $tx
% metapost default arrowhead angle is 45 degrees
%%%% Draw the axes
pickup pencircle scaled (gridwidth*1.0pt);
for i=xmin upto xmax: draw (i,ymin)*u--(i,ymax)*u; endfor;
for i=ymin upto ymax: draw (xmin,i)*u--(xmax,i)*u; endfor;

def opencircle(expr z, d, rgb) =
 save p;
 path p; background=white;
 p = fullcircle scaled (2.3333*d) shifted (z);
 fill p withcolor background;
 draw p withcolor (rgb) withpen currentpen scaled 0.5;

def solidcircle(expr z, d, rgb) =
    save p; path p;
    p = fullcircle scaled (2*d) shifted (z);
    filldraw p withcolor (rgb);

%% Horizontal labels;
xl[0] = thelabel.bot(\btex\large $-6$ etex, (xmin + tx*0,0)*u);
  unfill bbox xl[0];
  draw xl[0];
xl[1] = thelabel.bot(\btex\large $-5$ etex, (xmin + tx*1,0)*u);
  unfill bbox xl[1];
  draw xl[1];
xl[2] = thelabel.bot(\btex\large $-4$ etex, (xmin + tx*2,0)*u);
  unfill bbox xl[2];
  draw xl[2];
xl[3] = thelabel.bot(\btex\large $-3$ etex, (xmin + tx*3,0)*u);
  unfill bbox xl[3];
  draw xl[3];
xl[4] = thelabel.bot(\btex\large $-2$ etex, (xmin + tx*4,0)*u);
  unfill bbox xl[4];
  draw xl[4];
xl[5] = thelabel.bot(\btex\large $-1$ etex, (xmin + tx*5,0)*u);
  unfill bbox xl[5];
  draw xl[5];
xl[6] = thelabel.bot(\btex\large $1$ etex, (xmin + tx*7,0)*u);
  unfill bbox xl[6];
  draw xl[6];
xl[7] = thelabel.bot(\btex\large $2$ etex, (xmin + tx*8,0)*u);
  unfill bbox xl[7];
  draw xl[7];
xl[8] = thelabel.bot(\btex\large $3$ etex, (xmin + tx*9,0)*u);
  unfill bbox xl[8];
  draw xl[8];
xl[9] = thelabel.bot(\btex\large $4$ etex, (xmin + tx*10,0)*u);
  unfill bbox xl[9];
  draw xl[9];
xl[10] = thelabel.bot(\btex\large $5$ etex, (xmin + tx*11,0)*u);
  unfill bbox xl[10];
  draw xl[10];
xl[11] = thelabel.bot(\btex\large $6$ etex, (xmin + tx*12,0)*u);
  unfill bbox xl[11];
  draw xl[11];

%% Vertical labels;
yl[0] = thelabel.lft(\btex\large $-6$ etex, (0,ymin + ty*0)*u);
  unfill bbox yl[0];
  draw yl[0];
yl[1] = thelabel.lft(\btex\large $-5$ etex, (0,ymin + ty*1)*u);
  unfill bbox yl[1];
  draw yl[1];
yl[2] = thelabel.lft(\btex\large $-4$ etex, (0,ymin + ty*2)*u);
  unfill bbox yl[2];
  draw yl[2];
yl[3] = thelabel.lft(\btex\large $-3$ etex, (0,ymin + ty*3)*u);
  unfill bbox yl[3];
  draw yl[3];
yl[4] = thelabel.lft(\btex\large $-2$ etex, (0,ymin + ty*4)*u);
  unfill bbox yl[4];
  draw yl[4];
yl[5] = thelabel.lft(\btex\large $-1$ etex, (0,ymin + ty*5)*u);
  unfill bbox yl[5];
  draw yl[5];
yl[6] = thelabel.lft(\btex\large $1$ etex, (0,ymin + ty*7)*u);
  unfill bbox yl[6];
  draw yl[6];
yl[7] = thelabel.lft(\btex\large $2$ etex, (0,ymin + ty*8)*u);
  unfill bbox yl[7];
  draw yl[7];
yl[8] = thelabel.lft(\btex\large $3$ etex, (0,ymin + ty*9)*u);
  unfill bbox yl[8];
  draw yl[8];
yl[9] = thelabel.lft(\btex\large $4$ etex, (0,ymin + ty*10)*u);
  unfill bbox yl[9];
  draw yl[9];
yl[10] = thelabel.lft(\btex\large $5$ etex, (0,ymin + ty*11)*u);
  unfill bbox yl[10];
  draw yl[10];
yl[11] = thelabel.lft(\btex\large $6$ etex, (0,ymin + ty*12)*u);
  unfill bbox yl[11];
  draw yl[11];
%%%% Place the labels
if ((xmax-xmin)*(ymax-ymin) > 99):
label.top(\btex {\Large $ x $} etex, (xmax*u+1.125*(24/64)*v,1.125(4/64)*v));
label.rt (\btex {\Large $ y $} etex, (1.125*(4/64)*v,ymax*u+1.125*(24/64)*v));
label.top(\btex {\large $ x $} etex, (xmax*u+(24/64)*v,(4/64)*v));
label.rt (\btex {\large $ y $} etex, ((4/64)*v,ymax*u+(24/64)*v));
pickup pencircle scaled (axeswidth*1.0pt);
drawdblarrow (0,ymin-ahpos*ahlen)*u--(0,ymax+ahpos*ahlen)*u;
drawdblarrow (xmin-ahpos*ahlen,0)*u--(xmax+ahpos*ahlen,0)*u;




  • 1
    Imho the % after begingroup and endgroup in the opencircle definition are wrong. – Ulrike Fischer May 25 at 20:01
  • Deleted. Thanks. – W. Kehowski May 25 at 21:02
  • what did you change? – Thruston May 25 at 21:19
  • I deleted the % characters. – W. Kehowski May 26 at 0:09

The given code never worked: I tried it with working TeX Live distributions from 2015 to 2019, always getting the same error.

The .mp file that gets written out shows

def opencircle(expr z, d, rgb) = begingroupsave p;
 path p;
 p = fullcircle scaled (2.3333*d) shifted (z);
 fill p withcolor background;
 draw p withcolor (rgb) withpen currentpen scaled 0.5;

which is of course wrong. Remember that gmp reads the mpost environment with TeX conventions on, in order to do macro expansion. Thus the % symbols after begingroup and endgroup hide the endlines and the output is


which is of course wrong. You can add comments to your Metapost snippets, but ensure a space precedes % or the comment is on a line of its own. Metapost essentially ignores line breaks, which are simply translated to spaces.

Removing the wrong % characters yields the expected result.

enter image description here

  • Even with removing the comment characters it's not compiling. – W. Kehowski May 26 at 0:16
  • My apology. I thought I stated what distribution I was using: MiKTeX 2.9.7050 (64-bit). – W. Kehowski May 26 at 0:36
  • If I take the file generated from gmp and compile it from the command line I get the following: C:\Temp>mpost --interaction=errorstopmode --tex=latex mwe.mp This is MetaPost, version 2.00 (MiKTeX 2.9.7050 64-bit) (MiKTeX 2.9.7050 64-bit) (C:/Program Files/MiKTeX 2.9/metapost/base/mpost.mp (C:/Program Files/MiKTeX 2.9/metapost/base/plain.mp Preloading the plain mem file, version 1.004) ) (./mwe.mp No output and the log file is empty. Files containing asymptote code compile properly. Only metapost seems to be affected. – W. Kehowski May 27 at 3:51
  • You can check if your mpost invocation crashed by running echo %ERRORLEVEL% immediately afterwards. A very high (or negative value) signals an error condition (e.g., access violation). You also can check the Windows event viewer. – Christian Schenk May 27 at 8:29
  • I get -1073741819. What next? – W. Kehowski May 27 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.