[metapost] Difference between "mpost file.mp" and "mpost ./file.mp"

Dan Luecking luecking at uark.edu
Mon Sep 13 19:25:13 CEST 2010

At 04:49 AM 9/11/2010, Taco Hoekwater wrote:

>Hi all,
>>It could be a file time issue. Which platform are you on?
>It seems this was indeed the case. There is a fix in the metapost
>source repository for those that are interested in compiling a new
>metapost binary themselves.
>For everybody else: I expect to release metapost 1.212 within a month
>from now, and of course the fix will be included in that release.
>Until then, Dan suggested introducing a time-wasting loop as a

I didn't really _suggest_ such a loop; I used one simply to
verify that the issue was with file times.

I _would_ suggest the following two work-arounds, in this order:

First: Don't use the constructs ./file.mp (nor .\file.mp in windows).

Second: Don't use the TEX macro in a loop. Instead, mimic
the TEX macro to write a _single_ temp file for creating all
the labels in one picture array:

   picture P[];
   write "verbatimtex" to "mptextemp.mp";
   write "%&latex" to "mptextemp.mp";
   write "\documentclass[12pt]{article}" to "mptextemp.mp";
   write "\begin{document}" to "mptextemp.mp";
   write "etex" to "mptextemp.mp";
   for n=0 upto 15:
     write "P[" & decimal n & "] := btex {\small $"
       & decimal n &"$} etex;" to "mptextemp.mp";
   endfor % barring typos.
   write EOF to "mptextemp.mp";
   input mptextemp.mp;

After this, the 16 labels are available, already typeset
(in one latex run) as picture variables P[0] through P[15].
Use them inside the example loop instead of TEX(...):

   for n=0 upto 15: label(P[n],...); endfor

This avoids any file time issues as the file mptextemp.mp
is only created once instead of the same filename regenerated
16 times. It also saves time in slow cases (mpost in MiKTeX
2.8 is extraordinarily slow for me, even on a Win 7, Core 3i

If one has to do this frequently, the first five
lines to be written can be stored in a string variable and
written as one command.


Daniel H. Luecking
Department of Mathematical Sciences
Fayetteville, Arkansas

More information about the metapost mailing list