[Tex/LaTex] Using gmp with shell-escape in Windows 10, MiKTeX 2.9, WinEdt 9.1

miktexshell-escapewinedt

Windows 10, MiKTeX 2.9 64-bit, WinEdt Build: 20150731 (v. 9.1) – 64-bit. I have updated the filename database and all format files in MiKTex 2.9.

I am using the gmp package that allows MetaPost files to be part of your latex document. In order to use the package it is necessary to put EnableWrite18=t in your pdflatex.ini file. Adding –enable-write18 or –shell-escape in WinEdt did not work (separate issue, possibly). However, once I click on the pdftexify button in WinEdt and the compilation encounters a MetaPost file generated by gmp, a panel pops up saying that Metapost has stopped working. Everything seems to load properly–the .mp and .mpx files are there, but MetaPost crashes. Does anyone know what might be the problem? Here is a MWE for those wishing to try it out.

    \documentclass[10pt]{article}
    \usepackage{amsmath}
    %% use option 'nowrite' if graphics are stable
    \usepackage[shellescape,latex]{gmp}
    \usempxclass{article}
    \usempxpackage{amsmath}
    \setlength{\unitlength}{1cm}
    \begin{document}

    \begin{mpost}[name=mwe]
    numeric u; u:=1.0cm;
    draw (0,0)*u--(1,0)*u;
    label(\btex "A" etex, (0,0)*u);
    label(\btex "B" etex, (1,0)*u);
    \end{mpost}

    \usempost[width=4.0in]{mwe}

    \end{document}

Best Answer

As clearly stated in pdflatex.ini:

please do not edit this file

so revert your changes in that file and rebuild the format.

You should enable the --shell-escape feature when invoking your compiler.

To do that in WinEdt, if you wish to use the PDFTeXify compiler, go to Options -> Execution Modes, and add --tex-option=--shell-escape in the "Switches" field of this compiler, as in the image below.

enter image description here

If instead you want do that for PDFLaTeX, you can simply add --shell-escape in the corresponding field.

enter image description here

The --tex-option part is needed because PDFTeXify calls MiKTeX's texify.exe executable which requires that format.

Now your code should compile fine with this output:

enter image description here