# How to make written text within math mode appear using the font of the surrounding text in ConTeXt?

In some parts of my document, I have text inside of math mode, to position text, e.g.:

\math{
\overset{
\text{This text is above.}
}
{
\text{This text is below.}
}
}


I found that any text placed inside \text{} inside \math{} will appear using the Serif body font, even within environments defined as Sans Serif, e.g.:

\starttypescript[serif][stsong]
\definefontsynonym[stsong][name:stsong][features=chinese]
\stoptypescript

\starttypescript[sans][stheiti]
\definefontsynonym[stheiti][name:stheiti][features=chinese]
\stoptypescript

\starttypescript[serif][stsong]
\definefontsynonym[Serif][stsong][features=chinese]
\stoptypescript

\starttypescript[sans][stheiti]
\definefontsynonym[Sans][stheiti][features=chinese]
\stoptypescript

\definetypeface[stsong][rm][serif][stsong]
\definetypeface[stheiti][ss][sans][stheiti]

\setupbodyfont[stsong, 12pt]
\starttext
{\stheiti This is some text.\math{\text{This is some more text.}}This is yet some more text.}
\stoptext

• Placing font definitions inside \text{}, such as \text{\stheiti Text.} is not a good solution, because much of this text is in macros which can appear in different places, such as in San Serif chapter titles, or in the main Serif text of the document.
• Setting a single font for math mode will also not be suitable for the same reason.

How can I set the font inside text mode inside math mode to the font of the text surrounding it?

• The behavior you want is the default with \text in amsmath for LaTeX. Probably ConTeXt is trying to be too smart. :) – egreg Oct 20 '12 at 23:44
• I agree with @egreg. This is a bug in ConTeXt's implementation of \text. But why are you using math mode for aligning text? What exactly do you want to do? There are better solutions than resorting to math mode for alignment. – Aditya Oct 21 '12 at 2:05
• Your example works correctly for me producing fonts inside the \text command matching those of the surrounding text. I have ConTeXt ver: 2012.05.30 11:26 MKIV fmt: 2012.8.21 int: english/english. – Andrew Swann Oct 23 '12 at 9:56

It was a regression bug in ConTeXt. As Andrew Swann said, it worked correctly with MkIV fmt 2012.8.21 and now it also works correctly with MkIV 2012.10.22. Below is a minimal example:

\starttext
\startTEXpage[offset=3mm]
\switchtobodyfont[sans]
\math{
\overset{
\text{This text is above.}
}
{
\text{This text is below.}
}
}
\stopTEXpage
\stoptext


which gives