# Space between a|b in math mode? [duplicate]

For a context free grammar I need to write:

A -> a | b


My code for this is

$A \rightarrow a | b$


however this gives me something like

A -> a|b // wanted: a | b, note the space before and after the |


meaning there is no space between a|b.

How can I fix this?

Thanks for any hint!

## marked as duplicate by egreg, morbusg, David Carlisle, Claudio Fiandrino, cmhughesMar 7 '13 at 16:36

• Use \mid that will produce the same spacing as \rightarrow – egreg Mar 7 '13 at 16:00