7

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}
1
  • Enclose the \rightarrow in braces, as in {\rightarrow}. Otherwise it is acting as a math operator. The braces shield it from "operating" on the quotation marks. Feb 19, 2014 at 12:30

2 Answers 2

3

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.

0
1

As indicated in my comment, you must enclose the \rightarrow in braces to shield it from operating on the surrounding quotation marks.

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

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

$Op \mapsto Op {``{\rightarrow}\mrq\mrq} 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

\end{varwidth}
\end{document}

enter image description here

If you wanted math "space" outside of the quote marks, you could make the whole group a \mathrel:

\documentclass{standalone}
\usepackage{varwidth}
\usepackage{amsmath}
\DeclareMathSymbol{\mlq}{\mathord}{operators}{``}
\DeclareMathSymbol{\mrq}{\mathord}{operators}{`'}
\begin{document}
\begin{varwidth}{\linewidth}
$Op \mapsto Op \mathrel{``{\rightarrow}\mrq\mrq} Op$

$Op \mapsto Op \mathrel{\mlq{\rightarrow}\mrq} Op$
\end{varwidth}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .