TransWikia.com

Spacing around a custom operator with stacked elements using centernot

TeX - LaTeX Asked by Matt Samuel on December 7, 2020

I am using an operator with the definition

newcommand{tom}[2]{{displaystylemathrel{mathop{to}^{#1}_{#2}}}}

with negation

newcommand{ntom}[2]{centernot{displaystylemathrel{mathop{to}^{#1}_{#2}}}}

The operator looks like this, with markup utom km w:

enter image description here

and the negation looks like this, untom 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.

One Answer

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}{rightarrowmathrel{vphantom{not}}}
newcommand{n@tom@nto}{centernotrightarrow}
makeatother

begin{document}

$utom{k}{m}w$ $untom{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.

Answered by egreg on December 7, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP