0

I wish to define a mathematical symbol, similar to \odot, using TikZ. The symbol should thus scale appropriately in accordance with its context (e.g. inline math, footnotes, diagrams, etc.). As a template, I followed this related question. However, it doesn't appear to be scaling correctly in all contexts. Furthermore, the spacing around the symbol is subtly wrong.

Here is a minimal working example:

\documentclass{article}

\usepackage{mathtools} \usepackage{tikz-cd}

\newlength{\oh}

\newcommand{\ostar}{\mathbin{\vcenter{\hbox{\text{\settoheight{\oh}{$\odot$}\tikz[baseline=.45\oh]{\drawline width=.06\ohcircle[radius=.57\oh]node[overlay,yshift=-.025\oh]{\ensuremath{*}};}}}}}}

\begin{document}

\begin{align} f \odot g \ f \ostar g \ x^{f \odot g} \ x^{f \ostar g} \ \end{align} \vspace{-7ex} [\begin{tikzcd}[column sep=large,row sep=tiny] \cdot & \cdot \ \cdot & \cdot \ \arrow["{f \odot g}"{description}, from=1-1, to=1-2] \arrow["{f \ostar g}"{description}, from=2-1, to=2-2] \end{tikzcd}]

\end{document}

which produces:

\ostar in various contexts

As seen in the image, the size of \ostar is correct for normal size math and in the commutative diagram. However, it is too large in the superscript (with respect to \odot), even though it should be scaled proportionally to \odot (since all the dimensions are with respect to \oh). Furthermore, though it is a little hard to see in the image, there is less spacing around \ostar than around \odot in every place it is used.

I suspect there's a simple solution, but I haven't been able to figure it out. How can I fix the definition of \ostar so that it behaves the same as \odot?

(Note that I actually want to define more complicated symbols than \ostar using the same method, so alternative solutions like this one do not suffice for my purposes.)

varkor
  • 539
  • 2
  • 12
  • 1
    You should use \text{$\vcenter{...}$} in order to fix the size. But this won't work in tikzcd, because you're nesting tikzpicture inside tikzpicture. – egreg May 17 '23 at 10:52
  • @egreg: that's already a significant improvement, thank you. The spacing appears not to be perfect in tikzcd, but it is perhaps close enough to be acceptable. – varkor May 17 '23 at 12:05

1 Answers1

2

You can put the symbol in a savebox and use the scalerel package to give it the same size as \odot. Changing the inner sep of the node will make the * larger or smaller.

enter image description here

\documentclass{article}

\usepackage{scalerel} \usepackage{mathtools} \usepackage{tikz-cd}

\newsavebox{\circstar} \sbox{\circstar}{\kern.075em\tikz{\node[draw, circle, line width=.36pt, inner sep=.5pt]{$*$};}\kern.075em}

\newcommand{\ostar}{\mathbin{\scalerel*{\usebox{\circstar}}{\odot}}}

\begin{document}

\begin{align} f \odot g \ f \ostar g \ x^{f \odot g} \ x^{f \ostar g} \ \end{align} \vspace{-7ex} [\begin{tikzcd}[column sep=large,row sep=tiny] \cdot & \cdot \ \cdot & \cdot \ \arrow["{f \odot g}"{description}, from=1-1, to=1-2] \arrow["{f \ostar g}"{description}, from=2-1, to=2-2] \end{tikzcd}]

\end{document}

Sandy G
  • 42,558