[Tex/LaTex] Ampersand in math in ConTeXt

contextmath-mode

I'm afraid this is fairly obvious and has been asked many times, but I could not find the answer. I am having trouble getting an ampersand in a displayed formula in ConTeXt. I tried the obvious \&, and it seems fine outside math, i.e. this works:

\starttext
$\Pr$ (A \& B)
\stoptext

but this does not:

\starttext
\startformula
\Pr (A \& B)
\stopformula
\stoptext

(and using an unescaped '&' fails as well, unsurprisingly). Of course I could use \wedge or the word "and", but if at all possible I'd rather use an ampersand.

Best Answer

By default there is no such command in math mode. However, you can switch to text mode where \& is available:

\starttext
  \startformula
    A \text{\&} B
  \stopformula
\stoptext

If you use \asciimode you don't even need the backslash:

\asciimode
\starttext
  \startformula
    A \text{&} B
  \stopformula
\stoptext

To avoid wrapping the ampersand in \text add the following code to your document. It redefines \& for both, inline and display math.

\appendtoks
  \def\&{\text{\letterampersand}}
\to\everymathematics

\starttext
  \startformula
    A \& B
  \stopformula

  \math{C \& D}

\stoptext
Related Question