# Metapost crashes when adding tex labels

I am using Miktex 2.9 (64-bit) and TexnicCenter when compiling Metapost (version 1.504). My files will compile fine without labels. When I try to add a tex label, metapost crashes. I NEED HELP PLEASE!

Also, when compiling it is generating files with filenames like'mp755048' which have a .tex, .dvi, and .txt associated with the filename. The .dvi file contains the latex label by itself. The text file contains:

This is TeX, Version 3.1415926 (MiKTeX 2.9) (preloaded format=tex 2012.3.18)  1 FEB   2013 16:44
**mp755048.tex
("C:\Users\Documents\Research\Thesis - Paper 2\Graphs\mp755048.tex"
! Undefined control sequence.
l.2 \documentclass
{article}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., \hobx'), type I' and the correct
spelling (e.g., I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
l.3 \begin
{document}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., \hobx'), type I' and the correct
spelling (e.g., I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

[1] [1] )
Output written on mp755048.dvi (2 pages, 340 bytes).


A minimal example that fails:

prologues :=3;
verbatimtex
%&latex
\documentclass{article}
\begin{document}
etex

beginfig(1);
label(btex $x$ etex, origin);
endfig;
end;

-
Welcome to TeX.sx! I get an error regarding the misplaced word "vertices" (that I believe should go before etex), but once corrected I have no problem. – egreg Feb 1 '13 at 21:30
I had a feeling my code would work for others. I think there is something wrong with the programs files. I have already re-installed Miktex. Any other suggestions? – Jonelle Feb 1 '13 at 21:41
Can you try making a really minimal example that fails? The shorter is the code, the easier is to find the problem. – egreg Feb 1 '13 at 21:43
Yes. Even this crashes: prologues :=3; verbatimtex %&latex \documentclass{article} \begin{document} etex beginfig(1); label(btex $x$ etex, origin); endfig; end; – Jonelle Feb 1 '13 at 21:44
@jonelle: and is the generated output correct? – Aditya Feb 2 '13 at 4:56

I had exactly the same problem. My initial workaround was to cut and paste mp code into Troy Henderson's MetaPost Previewer (http://www.tlhiv.org/mppreview/), which worked magnificently. Code that compiled and ran there would not run and generated the same error messages as above. Not happy with that situation, I found this link (https://groups.google.com/forum/?hl=en&fromgroups=#!topic/fr.comp.text.tex/ilcOWIxWcP4) which is in French but includes a Google translator if you are so inclined. I followed the 12 step procedure outlined, and while I was in the MikTeX Options (Admin) program on the Formats tab, I noticed the mptopdf key was excluded, so I re-enabled this. After updating formats, MetaPost ran without a hitch! One problem relegated to the ash-heap of history. Since I changed a few things simultaneously, I'm not sure which was the culprit. At this point, I'm just happy to have a working MP system. Regards

-