[Tex/LaTex] wavy division sign wanted

math-modesymbols

I would like to find or create a math relation symbol that resembles a division sign, except that the horizontal bar would instead be a tilde (\sim). Can anyone help with this?

Best Answer

Here, I build a generic form with stacks, and then use scalerel package's

\ThisStyle{...\SavedStyle...}

and \mathchoice to make it work for the various mathstyles. The optional arguments to \genericform are the distances the under and over dots are vertically shifted. They can be tweaked to suit.

\documentclass{article}
\usepackage{stackengine}
\usepackage{graphicx}
\usepackage{scalerel}
\stackMath
\def\ccdot{\scalebox{1.15}{$\SavedStyle\cdot$}}
\def\genericform#1#2{\stackunder[#1]{\stackon[#2]{\SavedStyle\sim}{\ccdot}}{\ccdot}}
\def\altdiv{\mathbin{\ThisStyle{\mathchoice%
  {\genericform{-2.5pt}{-1.5pt}}%
  {\genericform{-2.5pt}{-1.5pt}}%
  {\genericform{-2.0pt}{-1.1pt}}%
  {\genericform{-1.4pt}{-0.8pt}}%
}}}
\begin{document}
$A \altdiv B ~~A \div B$\par
$\scriptstyle A \altdiv B ~~A \div B$\par
$\scriptscriptstyle A \altdiv B ~~A \div B$\par
\end{document}

enter image description here


Note: Modifications to scalerel package discussed below have been implemented into scalerel V1.6 (10 MAR 2014). New lengths that scale with the mathstyle, inside of \ThisStyle{}, are available as \LMex and \LMpt.

This answer got me thinking about an improvement to my scalerel package. In particular, the \ThisStyle{...\SavedStyle...} syntax allows me to access glyphs in the current mathstyle (because it internally performs a \mathchoice), but my answer above still requires an additional \mathchoice because lengths (even scalable ones like "ex") do not scale with the current mathstyle.

What I need is for \ThisStyle{} to additionally create a length that does scale with the current math style. So I do that below, and call it \LMex (Local Mathstyle "ex"). It is 1ex in \displaystyle and \textsstyle, 0.7ex in \scriptstyle and 0.5ex in \scriptscriptstyle (inside the argument of \ThisStyle).

In so doing, I can avoid an inefficient nesting of \mathchoicees and avoid the use of my \genericform altogether, if I express the length shifts of my stack in terms of multiples of \LMex.

\documentclass{article}
\usepackage{stackengine}
\usepackage{graphicx}
\usepackage{scalerel}
\stackMath
%%%%% scalerel MODIFICATION
\makeatletter
\newlength\LMex
\renewcommand\ThisStyle[1]{%
  \ifmmode%
    \def\@mmode{T}\mathchoice%
      {\edef\m@switch{D}\LMex=1ex\relax#1}%
      {\edef\m@switch{T}\LMex=1ex\relax#1}%
      {\edef\m@switch{S}\LMex=.7ex\relax#1}%
      {\edef\m@switch{s}\LMex=.5ex\relax#1}%
  \else%
    \def\@mmode{F}%
    \edef\m@switch{T}#1%
  \fi%
}
\makeatother
%%%%% END scalerel MODIFICATION
\def\ccdot{\scalebox{1.15}{$\SavedStyle\cdot$}}
\def\altdiv{\mathbin{\ThisStyle{%
  \stackunder[-.6\LMex]{\stackon[-.45\LMex]{\SavedStyle\sim}{\ccdot}}{\ccdot}}}}
\begin{document}
$A \altdiv B ~~A \div B$\par
$\scriptstyle A \altdiv B ~~A \div B$\par
$\scriptscriptstyle A \altdiv B ~~A \div B$\par
\end{document}

enter image description here