67

Is there a way to write the equivalent of \rightarrow in text mode?

I tried but it threw an error, and the math arrow complained about bad environment.

It doesn't need to be exactly the same arrow, I just want to write something like "A → B" as in A points to B.

5
  • 1
    You can use A$\,\to\,$B Commented Feb 20, 2015 at 18:24
  • 16
    Why not $\rightarrow$?
    – egreg
    Commented Feb 20, 2015 at 18:24
  • 2
    I hoped there's a cleaner way than making a math context just for the one arrow, but yeah that'll do the trick as well.
    – MightyPork
    Commented Feb 20, 2015 at 18:24
  • 1
    @MightyPork there's a text-mode option. See my answer below. Commented Feb 20, 2015 at 18:29
  • @c.p. Not here, they are names of nodes, not math related. If they were points, yeah.
    – MightyPork
    Commented Feb 20, 2015 at 18:34

3 Answers 3

91

You can use something like A$\,\to\,$B or A\textrightarrow B (in text mode) from the textcomp package:

\documentclass{article}
\usepackage{textcomp}

\begin{document}


A$\,\to\,$B

A\textrightarrow B

\end{document}

enter image description here

2
  • 17
    If you want space around the arrow, use this instead: A \textrightarrow{} B Commented Nov 4, 2016 at 22:14
  • 6
    BTW: List of all available symbols in textcomp package is available here. Unfortunately there is no \textleftrightarrow (equivalent of \leftrightarrow that is available in math mode). Commented Jan 3, 2017 at 10:55
5

With fontspec, you can simply paste the Unicode glyphs for arrows after selecting any font that contains them, or use commands such as \char"2194 or \symbol.

2

Try A \verb|->| B.

To me this is the simplest and most flexible solution, and renders nicely too (sure, it does not look like the right arrow in math mode but for many purposes it might be enough). You can control spacing very easily inside the verbatim. For instance, more spacing would be A \verb| -> | B. Both are shown below.

enter image description here

You must log in to answer this question.

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