# btex \begin{align} …\end{align} etex METAPOST issue

I seem to be having trouble getting my code to carry out any amsmath command with the btex--etex environment in a metapost file. The appropriate packages are defined withint my tex file, so I really have no idea what the problem is!

I will appreciate any help!

This is my mp code:

outputtemplate:="%j%c.mps";
beginfig(1)
defaultscale := 10pt/fontsize(defaultfont);
u:=1.1cm;
path p; p:=(0.1cm,u)--(0.1cm,u+0.5cm);
pair A;
A:=(0.8cm,0);
drawarrow p;
draw unitsquare scaled 1cm withpen pencircle scaled 0.5;
draw (-0.01cm,0)..(-0.01cm,2cm) dashed evenly scaled 0.8 withpen pencircle scaled 0.8 withcolor red;
draw (0,-0.01cm)..(2cm,-0.01cm) dashed evenly scaled 0.8 withpen pencircle scaled 0.8 withcolor red;
%drawarrow p;
for i=0 upto 2:
drawarrow p shifted (i*A/2);
endfor;
label.ulft(btex \begin{align}\sqrt{3} \\ u_{r}=0\end{align} etex, origin );

endfig;
bye


Thank you!

Metapost use TeX by default to compile the labels, even if you ask it to use LaTeX instead it does not now about align, it is missing the amsmath package. Try adding this

verbatimtex
%&latex
\documentclass{article}
\usepackage{amsmath,amssymb}
\begin{document}
etex


at the start of your Metapost file.

BTW: you may want to use align* instead, or even just the matrix env inside a $...$, using an environment is overkill in this case.

• I'd use \begin{aligned}...\end{aligned}, because a display environment doesn't really make sense. – egreg Apr 24 '14 at 12:08
• Thank you. It works. It would have helped if I had a proper look at the manual beforehand too! – user2822693 Apr 24 '14 at 13:04
• It's often easier to put two separate labels instead of a stack. – Thruston Apr 24 '14 at 17:12