Even numbers of \circ causes weird spacing

From the TeXbook (page 187, solution on page 326)

Exercise 19.7
B. L. User tried typing ‘\eqno(*)’ and ‘\eqno(**)’, and he was pleased to discover that this produced the equation numbers ‘(∗)’ and ‘(∗∗)’. [He had been a bit worried that they would come out ‘(*)’ and ‘(**)’ instead.] But then a few months later he tried ‘\eqno(***)’ and got a surprise. What was it?

When you type an asterisk in math mode, plain TeX considers * to be a binary operation. In the cases ‘(*)’ and ‘(**)’, the binary operations are converted to type Ord, because they don't appear in a binary context; but the middle asterisk in ‘(***)’ remains of type Bin. So the result was ‘(∗ ∗ ∗)’. To avoid the extra medium spaces, you can type ‘\eqno(*{*}*)’; or you can change \mathcode`*, if you never use * as a binary operation.

It doesn't matter if we're in an equation number (\eqno); the main issue is math mode where the behavior shows. Since \circ is a binary operation symbol just like *, you get the same.

If you want evenly spaced \circ symbols you can use

{\circ}\;{\circ}\;{\circ}\;{\circ}

Even better, define a suitable command:

\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\circs}{m}
 {
  \ensuremath
   {{
     {\circ}\prg_replicate:nn { #1 - 1 } { \; {\circ} }
   }}
 }
\ExplSyntaxOff

\begin{document}

$\circs{1}$

$\circs{2}$

$\circs{3}$

$\circs{4}$

$\circs{5}$

$\circs{6}$

$\circs{7}$

\end{document}

enter image description here


When you issue \show\circ you'll see it defined as \mathchar"220E. The first number in this definition points to the intrinsic "format" of the character. 2 denotes a binary operator which has a specific spacing around. So, \circ is considered a binary operator and therefore expects operands on either side. Odd-numbered \circs show better alignment as they supply "operands" on either side (barring accommodation for uniform spacing around consecutive \circs):

enter image description here

\documentclass{article}

\begin{document}

1 circ: $\circ$

2 circ: $\circ \circ$

2 circ: $\circ \circ {}$

3 circ: $\circ \circ \circ$

4 circ: $\circ \circ \circ \circ$

4 circ: $\circ \circ \circ \circ {}$

5 circ: $\circ \circ \circ \circ \circ $

6 circ: $\circ \circ \circ \circ \circ \circ$

6 circ: $\circ \circ \circ \circ \circ \circ {}$

7 circ: $\circ \circ \circ \circ \circ \circ \circ$

\end{document}

If you just want to list a number of \circs with the correct spacing, consider adding a empty math group at the end when using an even number of \circs. Alternatively, use {\circ} or \mathord{\circ} to avoid the surrounding space; \mathord turns its argument into a math ordinal.