# Ampersand in math in ConTeXt

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.

-
What do you mean, with you sent it too soon? –  Dave Mar 11 '13 at 10:04
I don't know Context, but in Latex, I would advise using the amsmath package and \text{\&}. Maybe you can adapt it to the Context syntax. –  T. Verron Mar 11 '13 at 10:31
Here's a workaround: \appendtoks\def\&{\text{\letterampersand}}\to\everymathematics –  Marco Mar 11 '13 at 11:42
Take a look at the \with symbol from the cmll font - that is an ampersand figure that has been adapted from the Computer Modern ampersand for use in maths mode. If you like that, @Marco's trick together with a font import is what you need. –  Charles Stewart Mar 11 '13 at 13:46
@T.Verron Thanks! Your solution works as well. As a matter of fact it seeems that just using text{\&} works (i.e., no need to \usemodule[amsmath], apparently). –  Thomas Junier Mar 11 '13 at 14:11

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

-

I used Detexify, which is a very usefull tool when you are looking for a special symbol. This way, I found the cmll package, containing the \with-command. I tried it in LaTeX:

\documentclass{minimal}
\usepackage{cmll}
\begin{document}
$A \with B$
\end{document}


and for me it worked well. I hope this works as well in ConTeX.

-
It needs to be a ConTeXt solution. –  percusse Mar 11 '13 at 10:14
@percusse There is a long-standing agreement that we can have answers illustrating how other formats would tackle an issue. They are mainly ConTeXt answer to LaTeX questions, but the same idea applies in reverse. –  Joseph Wright Mar 12 '13 at 11:01
@JosephWright Sure I didn't mean that the answer is not suitable. It was a reminder but maybe not in a well-constructed comment. –  percusse Mar 12 '13 at 11:04