TransWikia.com

Why is nsim thicker than sim?

TeX - LaTeX Asked by Jukka Suomela on December 31, 2020

Problem

For some reason, nsim looks like a negated bold version of sim, while I would expect it to look exactly like sim with a slash on top of it.


Examples

This seems to happen with mathdesign:

documentclass{article}
usepackage{graphicx}
usepackage{xcolor}
usepackage[charter]{mathdesign}
begin{document}
begin{center}
scalebox{10}{%
$sim$
$nsim$
makebox[0pt][l]{$nsim$}%
color{red}$sim$%
}
end{center}
end{document}

It looks like this (note that nsim is thicker than sim; it is easiest to see when we overlay a red sim on top of a black nsim):

mathdesign

And it also seems to happen with amssymb:

documentclass{article}
usepackage{graphicx}
usepackage{xcolor}
usepackage{amssymb}
begin{document}
begin{center}
scalebox{10}{%
$sim$
$nsim$
makebox[0pt][l]{$nsim$}%
color{red}$sim$%
}
end{center}
end{document}

It looks like this (again black nsim is visible under red sim):

amssymb


Questions

  1. Why does this happen? Isn’t nsim supposed to be a negated sim?

  2. How can I construct with usepackage[charter]{mathdesign} a symbol that looks like a negated version of sim? (Something like notsim is ugly.)

3 Answers

Since the issue seems to be with the definition of nsim, I suggest you redefine it:

makeatletter
renewcommand{nsim}{mathrel{mathpaletten@simrelax}}
newcommand{n@sim}[2]{%
  ooalign{%
    $m@th#1sim$cr
    hidewidth$m@th#1rotatebox[origin=c]{50}{$#1-$}$hidewidthcr
  }%
}
makeatother

For users unfamiliar with mathpalette: The mysteries of mathpalette

For general advice on designing your own symbols: How do you make your own symbol when Detexify fails?

For additional details regarding ooalign: https://tex.stackexchange.com/a/22375/125871

To use the above code, the call $ansim b_{ansim b_{ansim b}}$ produces the output enter image description here

Since the original sim command is used to redefine nsim, the thickness is equal:

enter image description here

Using mathdesign: enter image description here

enter image description here

Correct answer by Sandy G on December 31, 2020

It seems that it depends on the font — the nsim glyph is a different glyph and not made by composition (which, with the default fonts for article class, comes out quite ugly):

documentclass{article}
usepackage{graphicx}
usepackage{xcolor}
usepackage{amssymb}
begin{document}
begin{center}
scalebox{10}{%
$sim$
$nsim$
makebox[0pt][l]{$nsim$}%
color{red}$sim$%
}

scalebox{10}{%
$sim$
$notsim$
makebox[0pt][l]{$notsim$}%
color{red}$sim$%
}
end{center}
end{document}

enter image description here

With stix2 fonts things are (in my opinion) much better:

documentclass{article}
usepackage{graphicx}
usepackage{xcolor}
usepackage{stix2}
begin{document}
begin{center}
scalebox{10}{%
$sim$
$nsim$
makebox[0pt][l]{$nsim$}%
color{red}$sim$%
}

scalebox{10}{%
$sim$
$notsim$
makebox[0pt][l]{$notsim$}%
color{red}$sim$%
}
end{center}
end{document}

enter image description here

...and looking at the example, I think that amssymb is using the stix glyph under the hood...

Answered by Rmano on December 31, 2020

With amssymb, the thicksim and nsim are a pair, but sim and nsim are not. To get more consistent output, you can redefine sim to thicksim by letsimthicksim.

documentclass{article}
usepackage{amssymb}
usepackage{tikz}

begin{document}
begin{tikzpicture}[blend group=screen, scale=10, every node/.style={scale=10}]
  node[red] {$sim$};
  node[blue] {$nsim$};
  
  begin{scope}[xshift=10pt]
    node[red] {$thicksim$};
    node[blue] {$nsim$};
  end{scope}
end{tikzpicture}
end{document}

enter image description here

Related implementations:

% latex2e kernel
DeclareSymbolFont{symbols} {OMS}{cmsy}{m}{n}
DeclareMathSymbol{sim}      {mathrel}{symbols}{"18}

% amsfonts.sty
DeclareSymbolFont{AMSb}    {U}{msb}{m}{n}
% amssymb.sty
DeclareMathSymbol{thicksim} {mathrel}{AMSb}{"73}
DeclareMathSymbol{nsim}     {mathrel}{AMSb}{"1C}

Answered by muzimuzhi Z on December 31, 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