# Positioning apostrophe for xrightarrow in math mode

Generally, it is definitely OK to write something like $\rightarrow'$, and we will get

However, in case for xrightarrows, the position of apostrophe would be quite weird, e.g. writing $\xrightarrow{\sigma}'$ results in

as LaTeX thinks apostrophe belongs to the arrow with its text above. So I'd like to know is it optimal way to put the apostrophe back to the "normal" position as for rightarrows?

P.S. I've attempt to use \mbox{$'$}, the vertical position is much better but it moves the apostrophe to the right side:

You can add an empty group to lower the prime. To preserve spacing, you must make the \xrightarrow an ordinary symbol by enclosing it in braces {...}, and make the result a \mathrel again.

\documentclass[a4paper,12pt]{article}

\usepackage{amsmath}
\newcommand*{\xrightarrowprime}[2][]{\mathrel{{\xrightarrow[#1]{#2}}{}'}}

\begin{document}

$a \to b$

$a\to' b$

$a \xrightarrow{\sigma} b$

$a \xrightarrowprime{\sigma} b$

$a \xrightarrowprime[x+y+z]{\sigma} b$

\end{document}


• I have removed my answer. My compliments. Nov 5 '19 at 12:18
• @Sebastiano Thx but you could have left it there. With a small \mathrel correction it would've been a perfectly acceptable answer. Nov 5 '19 at 17:34