[Tex/LaTex] Quotation marks around operator in math mode

math-modepunctuation

I want to create formulae where the \rightarrow is enclosed in double quotation marks and appears like any other word in a formula. What I'm getting instead, are formulae where these quotation marks are drawn to adjacent words, leaving a gap between the quotation marks and the \rightarrow.

Example: I'm getting Some'' -> ''Word. I want Some ''->'' Word.
The sequence ''->'' should be treated the same as Some or Word.
The -> (\rightarrow) should be rendered as if it were used in an arbitrary math-environment.
I have looked at this answer, but I could not turn that into something useful, as my MWE will show.
Also, I do not wish to break up my math environment, since the quotation marks are part of the formulae.

bad rendering

\documentclass{standalone}
\usepackage{varwidth}
\usepackage{amsmath}
\DeclareMathSymbol{\mlq}{\mathord}{operators}{``}
\DeclareMathSymbol{\mrq}{\mathord}{operators}{`'}

\begin{document}
\begin{varwidth}{\linewidth}
$Op \mapsto Op ``\rightarrow'' Op$%large gap on left; ' treated as prime

$Op \mapsto Op {``\rightarrow''} Op$%large gap on left; ' treated as prime

$Op \mapsto Op \mlq\rightarrow\mrq Op$%large gaps on left & right

$Op \mapsto Op {\mlq\rightarrow\mrq} Op$%large gaps on left & right

Quotation marks close\\
to arrow: ``$\rightarrow$''
\end{varwidth}
\end{document}

Best Answer

Declare \mlq and so on as \mathrel, because TeX doesn't add space between consecutive relation symbols:

\documentclass[varwidth,border=3pt]{standalone}
\usepackage{amsmath}
\DeclareMathSymbol{\mlq}{\mathrel}{operators}{``}
\DeclareMathSymbol{\mrq}{\mathrel}{operators}{`'}
\DeclareMathSymbol{\mlqq}{\mathrel}{operators}{"5C}
\DeclareMathSymbol{\mrqq}{\mathrel}{operators}{`"}

\begin{document}

$Op \mapsto Op \mlq\rightarrow\mrq Op$

$Op \mapsto Op \mlqq\rightarrow\mrqq Op$

Quotation marks close to arrow: ``$\rightarrow$''
\end{document}

enter image description here

If you need quotes around other symbols, you can follow a different path; declare the quotes as ordinary symbols (with \mathord) and define

\newcommand{\qto}{\mathrel{\mlq}\to\mathrel{\mrq}}
\newcommand{\qqto}{\mathrel{\mlqq}\to\mathrel{\mrqq}}

so you can have something like

$\mlq A\mrq \qqto \mlqq B\mrqq$

without worrying about spacings.