# Metapost graphics not aligned in ConTeXt TABLE

I am using TABLE to design map legend. Symbols should be middle-aligned. As said in the title, the metapost graphics used as symbols are not aligned in my TABLE environment (column 1 and 3), whereas text is aligned as it should be ("cas" in row 3).

\startreusableMPgraphic{tourisme}
pickup pencircle scaled 2 ;
path p ;
p:= unitsquare xscaled 30 yscaled 15 ;
draw p withcolor red ;
\stopreusableMPgraphic

\startreusableMPgraphic{ballon}
path p ;
p:= (10,0) -- (0,15) .. (10,30) .. (20,15) -- cycle ;
fill p withcolor red ;
\stopreusableMPgraphic

\starttext
\setupTABLE[column][1,3][width=4em,align={middle,lohi}]
\setupTABLE[column][2,4][width=0.42 \textwidth,align=lohi]
%\setupTABLE[][]
\bTABLE
\bTR \bTH \eTH \bTH I. My first part\eTH \bTH \eTH \bTH II. My second part \eTH \eTR
\bTR \bTD \reuseMPgraphic{tourisme} \eTD \bTD forêts \eTD  \bTD \reuseMPgraphic{tourisme} \eTD \bTD some very long text to make sure that alignment works as I want\eTD\eTR
\bTR \bTD \reuseMPgraphic{tourisme} \eTD \bTD some very long text to make sure that alignment works as I want \eTD \bTD cas \eTD \bTD a nice castle \eTD \eTR
\bTR \bTD \eTD \bTD \eTD \bTD \reuseMPgraphic{ballon} \eTD \bTD montgolfière (tourisme vert) \eTD \eTR
%\bTR \bTD \eTD \bTD \eTD \bTD \eTD \bTD \eTD \eTR
\eTABLE

\stoptext


How can I fix this?

• Add \leavevmode just before your \reuseMPgraphic commands. – Thruston Nov 12 '17 at 19:53
• @Thruston. It fixes it. Could you convert your comment to an answer I will accept? If you don't mind, it would be great to explain why this \leavevmode is required. I still do not understand how do \vbox work, even after reading TeX by Topics. – sztruks Nov 12 '17 at 19:59

When you are including graphics in a table like this, you need to make sure that TeX is in horizontal mode in order to get the text alignment to apply to the included graphic (apparently). You can force the cells into this mode using the \leavevmode primitive command.

In this case, I guess you will be using lots of symbols, so you might consider making a macro to do the work for you, as I have done here:

\startreusableMPgraphic{tourisme}
pickup pencircle scaled 2 ;
path p ;
p:= unitsquare xscaled 30 yscaled 15 ;
draw p withcolor red ;
\stopreusableMPgraphic
\def\ttour{\leavevmode\reuseMPgraphic{tourisme}}

\startreusableMPgraphic{ballon}
path p ;
p:= origin -- (-10,15) .. (0,30) .. (10,15) -- cycle ;
fill p withcolor red ;
\stopreusableMPgraphic
\def\tball{\leavevmode\reuseMPgraphic{ballon}}

\starttext
\setupTABLE[column][1,3][width=4em,align={middle,lohi}]
\setupTABLE[column][2,4][width=0.42 \textwidth,align=lohi]
\bTABLE
\bTR
\bTH \eTH
\bTH I. My first part\eTH
\bTH \eTH
\bTH II. My second part\eTH
\eTR
\bTR
\bTD \ttour\eTD
\bTD forêts\eTD
\bTD \ttour\eTD
\bTD some very long text to make sure that alignment works as I want\eTD
\eTR
\bTR
\bTD \ttour \eTD
\bTD some very long text to make sure that alignment works as I want\eTD
\bTD cas\eTD
\bTD a nice castle\eTD
\eTR
\bTR
\bTD \eTD
\bTD \eTD
\bTD \tball\eTD
\bTD montgolfière (tourisme vert)\eTD
\eTR
\eTABLE

\stoptext