4

Similar to this question, I want to write some text above $\nrightarrow$. This is what I could do:

\documentclass{article}
\usepackage{mathtools}
\usepackage{amssymb}

\begin{document}

$\nrightarrow$

$\nrightarrow^{\text{Hello}}$

\end{document}

As you can see, the text is not properly aligned.

So, I seek help in putting the text right on top.

Additionally, it would be appreciated to faciliate extending the arrow to fit the text.

hola
  • 4,026
  • 3
  • 35
  • 72

2 Answers2

9

Maybe something like

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}

\makeatletter \newcommand{\xnrightarrow}[2][]{% \mathrel{% \vphantom{\xrightarrow[#1]{#2}}% \ooalign{\hidewidth\neg@arrow\hidewidth\cr$\m@th\xrightarrow[#1]{#2}$\cr}% }% } \newcommand{\neg@arrow}{% $\m@th\vcenter{\hbox{% \rotatebox[origin=c]{-45}{\scalebox{1.5}[1]{$\m@th\scriptscriptstyle|$}}% }}$ } \makeatother

\begin{document}

\begin{gather} A\xnrightarrow{\text{hello}}B \ A\xnrightarrow{\text{hello again}}B \end{gather}

\end{document}

where a negation symbol is superimposed to the standard \xrightarrow. The negation symbol is a fattened bar which is rotated.

enter image description here

egreg
  • 1,121,712
4

Maybe \substack is an option for you:

\documentclass{article}
\usepackage{amsmath}
\usepackage{mathtools}
\usepackage{amssymb}
\begin{document}
\[
    \substack{Hello\\\nrightarrow}
\]

\end{document}

enter image description here

Roland
  • 6,655
  • 3
    See the word Extensible in the OPs question. This solution does not provide an extensible negated arrow – daleif Oct 08 '21 at 10:05
  • @daleif Maybe \substack is an option for you: He probably thought that his answer will be helpful if this the only way or no other answer or hope that OP might use this for his solution. But of course this is not an direct-answer, but that's the point of maybe \lorem is an option... – NotStanding with GoGotaHome Oct 08 '21 at 13:00