TransWikia.com

How may I negate long equality signs?

TeX - LaTeX Asked on May 16, 2021

As an answer to How do I make a long identity sign? @egreg offered the solutions:

documentclass{article}
usepackage{amsmath,color}

makeatletter
newlength{longeq@wd}
newcommand{longeq}[1][2]{mathrel{mathpalettelongeq@{#1}}}
newcommand{longeq@}[2]{%
  begingroup
  settowidthlongeq@wd{$m@th#1=$}%
  makebox[#2longeq@wd][s]{%
    $m@th#1mspace{1mu}$%
    ifdim#2pt<2pt
      $m@th#1{=}hss{=}$%
    else
      $m@th#1{=}kern-0.5longeq@wdcleaderslongeqfill@{#1}hfilkern-0.5longeq@wd{=}$%
    fi
    $m@th#1mspace{1mu}$%
  }%
  endgroup
}
newcommand{longeqfill@}[1]{hbox{$m@th#1mspace{-3mu}{=}mspace{-3mu}$}}
makeatother

begin{document}

makeatletter

$a==b$

$alongeq b$

$alongeq[1.25]b$

$alongeq[1.5]b$

$alongeq[1.75]b$

$alongeq[3]b$

end{document}

How may I negate the long identity signs as with $neq$?

2 Answers

Use centernot:

documentclass[draft]{article}
usepackage{amsmath,centernot}

makeatletter
newlength{longeq@wd}
newcommand{nlongeq}[1][2]{centernot{longeq[#1]}}
newcommand{longeq}[1][2]{mathrel{mathpalettelongeq@{#1}}}
newcommand{longeq@}[2]{%
  begingroup
  settowidthlongeq@wd{$m@th#1=$}%
  makebox[#2longeq@wd][s]{%
    $m@th#1mspace{1mu}$%
    ifdim#2pt<2pt
      $m@th#1{=}hss{=}$%
    else
      $m@th#1{=}kern-0.5longeq@wdcleaderslongeqfill@{#1}hfilkern-0.5longeq@wd{=}$%
    fi
    $m@th#1mspace{1mu}$%
  }%
  endgroup
}
newcommand{longeqfill@}[1]{hbox{$m@th#1mspace{-3mu}{=}mspace{-3mu}$}}
makeatother

begin{document}

makeatletter

$a==b$

$alongeq bnlongeq c$

$alongeq[1.25]bnlongeq[1.25] c$

$alongeq[1.5]bnlongeq[1.5] c$

$alongeq[1.75]bnlongeq[1.75] c$

$alongeq[3]bnlongeq[3] c$

end{document}

enter image description here

Correct answer by egreg on May 16, 2021

Employing the alternate solution at the cited answer, if you end up using an odd number of = signs for the construction, just apply not to the middle one.

documentclass{article}
newcommandlongeq{mathrel{{=}mkern-4mu{=}mkern-4mu{=}}}
newcommandnlongeq{mathrel{{=}mkern-4mu{not=}mkern-4mu{=}}}
begin{document}
$xlongeq y nlongeq z$
end{document}

enter image description here

Werner, in a comment below, notes a simpler syntax of

newcommandlongeq{=joinrel=joinrel=}
newcommandnlongeq{=joinrelnot=joinrel=}

However, the joinrel (join relation) macro uses a 3mu shift to achieve the overlay, whereas, my original definition chose the shift as 4mu, making the overall length slightly shorter in my original case, by comparison.

If one finds it too wide, jack up the negativity of the mkern. Here it is, to -10mu (was -4mu above):

enter image description here

Answered by Steven B. Segletes on May 16, 2021

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