# How to align text on baseline in MetaFun without using setMPtext?

I want to draw several pieces of text that should be aligned so I need to be able to place these texts according to their baseline.

Looking at the MetaFun manual, pages 143-144, it is explained that baseline alignment can be achieved through several methods:

• defining text with \setMPtext and calling draw on the object returned by \MPbetex,
• draw the object returned by textext.origin,
• draw the object returned by thelabel.origin.

However, when I test these three methods with the following code, only the first one works properly.

\starttext
\setMPtext {1} {Foo}
\setMPtext {2} {Bap}

\startMPpage
draw \MPbetex{1} shifted (0,0);
draw \MPbetex{2} shifted (0.5cm,0);

draw textext.origin("Foo") shifted (0,-1cm);
draw textext.origin("Bap") shifted (0.5cm,-1cm);

draw thelabel.origin("Foo",(0,-2cm));
draw thelabel.origin("Bap",(0.5cm,-2cm));
\stopMPpage

\stoptext


Is their a way to align text on baseline without needing to "pre-declare" all pieces with \setMPtext?

## 1 Answer

The definition of \MPbetex essentially reads:

\def\MPbetex #1{btex \begincsname\??mptext#1\endcsname\space etex}


That is, it just receives the string stored using \MPtext and places it between btex ... etex. Of course you can also do that by hand.

\startMPpage
draw btex Foo etex shifted (0,0);
draw btex Bap etex shifted (0.5cm,0);
\stopMPpage


• I thought textext was the exact equivalent of placing text between btex..etex. My bad. – Silverspur Aug 11 at 9:59
• I have two follow-up questions: how is is possible to insert the value of a MetaPost string variable between btex..etex? And why the alignment is different with textext? – Silverspur Aug 11 at 10:23
• @Silverspur To get the value of a variable set with \setMPtext{1}{...} between btex ... etex use something like draw btex \MPtext{1} etex;. Regarding textext I'm not 100% sure but I believe that it is simply a shortcut for thelabel(btex ... etex). – Henri Menke Aug 11 at 16:04
• Ok. I just happened to find on another question that textext.d(...) also aligns on baseline. – Silverspur Aug 12 at 8:58