How does LaTeX renders a \div?

Assuming TeX Live on a Unix system with bash, open a terminal window and type

texdef -t latex div

and return. You'll get the following info:

> texdef -t latex div

\div:
\mathchar"2204


\the\div:
8708

that's not really so much interesting, perhaps, for the non cognoscenti. The same information would be issued by doing \show\div in an interactive session or by typing

\texttt{\meaning\div}

in a document and typesetting it.

However, being \div a core math symbol, the real definition can be found in fontmath.ltx; type

grep '\\div\b' $(kpsewhich fontmath.ltx)

and the terminal will print

\DeclareMathSymbol{\div}{\mathbin}{symbols}{"04}

which is indeed the definition the LaTeX kernel does of \div.

You find all the core math symbols definitions by doing something like

less $(kpsewhich fontmath.ltx)

The OP states that "I want to reinvent the wheel..."

I would note that, to make your own personal version of \div, one does not necessarily have to know the exact formulation of the original. In particular, the code

\let\svdiv\div
\def\div{...\svdiv...}

will allow a new \div to be defined in terms of the original. Furthermore, in the case of \div, as Joseph noted in a comment, \show\div reveals the definition as \mathchar"2204 indicating there is no "code" per se for the division sign, but rather it merely points to a glyph slot of the font intself (slot 4 of the math symbol font).

\documentclass{article}
\usepackage{stackengine}
\begin{document}
Here is the new \textbackslash div:
\let\svdiv\div
\def\div{\mathbin{\ensurestackMath{\stackinset{c}{.002ex}{c}{-.06ex}{\circ}{\svdiv}}}}
$A \div B$
\end{document}

enter image description here

If one did not wish to redefine the original, but only to define \mydiv in terms of the original, then this:

\documentclass{article}
\usepackage{stackengine}
\begin{document}
Here is \textbackslash mydiv:
\def\mydiv{\mathbin{\ensurestackMath{\stackinset{c}{.002ex}{c}{-.06ex}{\circ}{\div}}}}
$A \mydiv B$
\end{document}

Tags:

Macros