I want to define a simple shape and use it as a binary math operator. This implies that it should scale when used as a subscript (e.g., the same behavior as \bigcirc
). My attempts so far led me here:
\documentclass{article}
\usepackage{tikz,amsmath}
\DeclareRobustCommand{\myop}{%
\mathbin{\text{\tikz \node[circle,draw=black,scale=0.4] () {$r$};}}}
\begin{document}
$A \bigcirc B$ $_{A \bigcirc B}$
$A \myop B$ $_{A \myop B}$
\end{document}
As one can see, the TikZ variant doesn't behave well: in the first case, the shape is smaller than the operands, while it is pretty much of the same height in the second one. Removing the scale
, adding some minimum size=0mm,inner sep=0mm
, etc. did not change anything to the problem. Hence:
Question: How can I obtain a smooth scaling of the operator?
\text
is basically doing themathchoice
here. I'm really searching for an option that keeps the tikz (because I may have something more complex) and that avoids amathchoice
. In a way, I'd like to be able to say "Let $x$ be the height of an "o" in the current mode, then scale the tikz picture to $x$."\text
goes a long way to make it easier. However, experiment with\DeclareRobustCommand{\myop}{\mathbin{\text{\rule{1mm}{.7em}}}}
or similar, and you'll see that it does not scale properly. What I'd really like to have, again, is something like "Put 'A' in a vbox, and scale the symbol to the height of that vbox." I just can't seem to be able to do that, because of evaluation timing.