Blog Moved

Saturday, March 18, 2017

LaTeX Notation for Numerals

It is common in meta-mathematics to use the notation n to mean the numeral for the number n, that is: S...S(0), where S is a symbol for successor and there are n S's in the numeral for n. In LaTeX, one can typeset this notation using \overline{n} in math mode. Unfortunately, this does not always look very good: The height of the bar will vary with the height of the contained character(s), so the heights of the bars in \overline{n} and \overline{k} will not match.

The solution is to use a 'strut': an invisible (because 0 width) rule that functions only to set the height of the bar:
\newlength{\numheight}
\setlength{\numheight}{\fontcharht\font`0}
\newcommand\numeral[1]{\overline{\rule{0pt}{\numheight}#1}

It would perhaps be better to use the current font in \numheight, but I've never had a problem with this in practice.

No comments:

Post a Comment

Comments welcome, but they are expected to be civil.
Please don't bother spamming me. I'm only going to delete it.