Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
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. –  Steven B. Segletes Feb 19 at 12:30
add comment

2 Answers

up vote 3 down vote accepted

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.

share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.