# What determines where MetaPost searches for a .mpx file?

Hefferon, Jim S. jhefferon at smcvt.edu
Fri Jul 5 21:01:52 CEST 2019

Hello,

Background: I have a large LaTeX project, a book.  I am refactoring it to put things not all in one directory.  I am compiling the book when I am in the directory src/ and one directory is src/gr/mp/, which contains the MetaPost file src/gr/mp/ch1.mp for the first chapter, on Gaussian reduction.

I am using latexmk, in the hope of making it compilable on Linux, Mac, and Windows, if that is relevant.

Question: I can get ch1.mp to input the LaTeX .sty files that I want, and to input my personal .mp files, by telling latexmk this.  (These directories are relative to src/, which is the dir in which I run latexmk.  The command prepends the string to the variable.)

ensure_path( 'TEXINPUTS', './/' );
ensure_path( 'MPINPUTS', './mp//' );

But I am stumped when I get this error.

This is MetaPost, version 1.999 (TeX Live 2015/Debian) (kpathsea version 6.2.1)
(/usr/share/texlive/texmf-dist/metapost/base/mpost.mp
(/usr/share/texlive/texmf-dist/metapost/base/plain.mp
Preloading the plain mem file, version 1.005) ) (./gr/mp/ch1.mp (./mp/jh.mp
(/usr/share/texlive/texmf-dist/metapost/base/boxes.mp)
(/usr/share/texlive/texmf-dist/metapost/base/graph.mp
(/usr/share/texlive/texmf-dist/metapost/base/marith.mp
(/usr/share/texlive/texmf-dist/metapost/base/string.mp))
(/usr/share/texlive/texmf-dist/metapost/base/format.mp
(/usr/share/texlive/texmf-dist/metapost/base/string.mp)
(/usr/share/texlive/texmf-dist/metapost/base/texnum.mp
>> texnum.mp
>> texnum.mpx
! ! Unable to read mpx file.
l.17 init_numbers(btex
$-$etex, btex$1$etex, btex${\times}10$etex,
Transcript written on ch1.log.
Rule 'cusdep mp 1 gr/mp/ch1', function 'mpost'
failed with return code = 768

(The final two lines are from latexmk.)   In short, I believe that I need to tell it where to look in order to do the "btex .. etex" thing.  This does not work.

ensure_path( 'MPSUPPORT', './/' );

If I run the appropriate command while in the dir src/gr/mp then it all compiles.

$MPINPUTS="../../mp//:$MPINPUTS" TEXINPUTS="../../sty:\$TEXINPUTS" mpost ch1

so I believe the .mp file is OK.

Any suggestions as to how to influence where MetaPost looks for those files?  Someone telling me that I have completely the wrong idea would also be a help.

Thanks,
Jim

----------
Remember when the Panama Papers came out and revealed an enormous conspiracy to dodge taxes and hoard wealth in offshore accounts? That was fun, huh?