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.

2 Answers 2

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

4
  • remove "maybe" :). assume that he is wanting it, OP would edit the question or comment you about if it wasn't the solution. Commented Oct 8, 2021 at 10:23
  • @VScode_fanboy Maybe, "maybe" is just politeness!
    – hola
    Commented Oct 8, 2021 at 11:28
  • @VScode_fanboy If nothing better comes along…
    – egreg
    Commented Oct 8, 2021 at 12:04
  • @egreg Yeah of course. No need to change it even if it is accepted. EDIT: it IS. Commented Oct 8, 2021 at 12:56
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

2
  • 3
    See the word Extensible in the OPs question. This solution does not provide an extensible negated arrow
    – daleif
    Commented Oct 8, 2021 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... Commented Oct 8, 2021 at 13:00

You must log in to answer this question.

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