2

I am using an operator with the definition

\newcommand{\tom}[2]{{\displaystyle\mathrel{\mathop{\to}^{#1}_{#2}}}}

with negation

\newcommand{\ntom}[2]{\centernot{\displaystyle\mathrel{\mathop{\to}^{#1}_{#2}}}}

The operator looks like this, with markup u\tom km w:

enter image description here

and the negation looks like this, u\ntom km w:

enter image description here

Notice in \tom the u and w are smashed up against the arrow, whereas in the negation there is spacing around it. I'm not sure which one looks better, but is there a way to keep it consistent?

I'm also not too comfortable with using \displaystyle, but it was the only way I could see to ensure the k and m stay above and below the arrow in \mathrel/\mathop.

7
  • the \mathrel is being negated by the outer {} which makes a mathord. You can use \limits rather than displaystyle to force the over position Commented Nov 1, 2020 at 19:50
  • Note you might replace \tom with a simple \xrightarrow[m]{k}.
    – Bernard
    Commented Nov 1, 2020 at 19:54
  • @Bernard I didn't know about that, thanks. I just tried it though and when I do k-1 instead of k it lengthens the arrow, and I'm not sure how I feel about that. Commented Nov 1, 2020 at 20:01
  • @DavidCarlisle What's the syntax for \limits? I'm trying various things and I get massive numbers of errors. Commented Nov 1, 2020 at 20:05
  • @DavidCarlisle Nevermind, I got it, thanks. Spacing problem remains though. Commented Nov 1, 2020 at 20:06

1 Answer 1

2

You can keep it consistent:

\documentclass{article}
\usepackage{amsmath,centernot}

\makeatletter
\newcommand{\tom}{\n@tom{\n@tom@to}}
\newcommand{\ntom}{\n@tom{\n@tom@nto}}

\newcommand{\n@tom}[3]{\overunderset{#2}{#3}{#1}}

\newcommand{\n@tom@to}{\rightarrow\mathrel{\vphantom{\not}}}
\newcommand{\n@tom@nto}{\centernot\rightarrow}
\makeatother

\begin{document}

$u\tom{k}{m}w$ $u\ntom{k}{m}w$

\end{document}

enter image description here

The seemingly mysterious programming style is aimed of splitting the job in layers. One main macro \n@tom takes as first argument the type of arrow and then the top and bottom limits. The two types of arrow are defined separately, so as to make it easier to modify just them.

For instance, if we load amssymb instead of centernot and change the two final definitions into

\newcommand{\n@tom@to}{\rightarrow}
\newcommand{\n@tom@nto}{\nrightarrow}

we'd get

enter image description here

which I think is better.

1
  • I found an alternative solution that looks the same, using Bernard's suggestion: \xrightarrow[\mathclap{#2}]{\mathclap{#1}} and \centernot on that. I have to think about the \nrightarrow. Thanks for your answer. Commented Nov 1, 2020 at 20:56

You must log in to answer this question.

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