# How can I typeset the math symbol with a circle and a rectangle attached to it?

I would like to use a math-symbol, which looks like the following picture (a circle with a rectangle attached to it). Is there a package which provides such or if not, how can I create it by myself?

I tried using detextify but did not get any satisfying result.

• Welcome to TeX.SX! Does the symbol have a name? – Bobyandbob Aug 1 '17 at 9:49
• @Bobyandbob OP said detexify didn't list an appropriate symbol. Are you saying to keep trying, because you found it using detexify? – Earthliŋ Aug 1 '17 at 9:52
• Is this symbol your ad hoc invention, or did you find it in some math publication? What should it denote? – jk - Reinstate Monica Aug 1 '17 at 9:53
• Have you searched through the Comprehensive LaTeX Symbol List? – Werner Aug 1 '17 at 10:13
• I did not find it in any publication. It will denote a geometric construction in work in progress of mine since the construction resembles the symbol in a simplified case. – SearchingSymbols Aug 9 '17 at 9:59

Without additional guidance, I made it based on \circ and defined it as \mathbin.

For a version that only works in the regular math size:

\documentclass{article}
\usepackage{xcolor}
\usepackage{stackengine}
\newcommand\mathkey{%
\mathbin{\stackinset{r}{-.98pt}{c}{.3pt}{%
\def\stackalignment{l}%
\stackon[-.85pt]{\rule{2pt}{1.2pt}}{\textcolor{white}{\rule{1.65pt}{0.45pt}}}%
}{$\circ$}\kern1.2pt}%
}
\begin{document}
$A\mathkey B$
\end{document}


For the version that works across math styles:

\documentclass{article}
\usepackage{xcolor}
\usepackage{stackengine,scalerel}
\newcommand\mathkey{%
\mathbin{\scalerel*{\stackinset{r}{-.98pt}{c}{.3pt}{%
\def\stackalignment{l}%
\stackon[-.85pt]{\rule{2pt}{1.2pt}}{\textcolor{white}{\rule{1.65pt}{0.45pt}}}%
}{$\circ$}\kern1.2pt}{\circ}}%
}
\begin{document}
$A\mathkey B$

$\scriptstyle A\mathkey B$

$\scriptscriptstyle A\mathkey B$
\end{document}


Note that the final \circ in the definition of \mathkey defines the vertical footprint of the \mathkey symbol. Thus, one could change that to something else, let's say X, in order to enlarge the resulting \mathkey:

\documentclass{article}
\usepackage{xcolor}
\usepackage{stackengine,scalerel}
\newcommand\mathkey{%
\mathbin{\scalerel*{\stackinset{r}{-.98pt}{c}{.3pt}{%
\def\stackalignment{l}%
\stackon[-.85pt]{\rule{2pt}{1.2pt}}{\textcolor{white}{\rule{1.65pt}{0.45pt}}}%
}{$\circ$}\kern1.2pt}{X}}%
}
\begin{document}
$A\mathkey B$

$\scriptstyle A\mathkey B$

$\scriptscriptstyle A\mathkey B$
\end{document}


Prepare a keyhole.mp file containing

beginfig(1);
w=18pt;
h=10pt;
o=1pt;
r=h/2;
pickup pencircle scaled 1pt;
lft z1=(o,r);
top z2=(r+o,h);
bot z4=(r+0,0);
rt z3=(2r+o,h/2);
path circlepart;
circlepart=z1..z2..z3..z4..cycle;
z5=point 2-1/4 of circlepart;
z6=(w-o,y5);
z7=(w-o,y8);
z8=point 2+1/4 of circlepart;
draw z1..z2..z5--z6--z7--z8..z4..cycle;
endfig;
end.


This is inspired from “lightbulb” in the Comprehensive List of LaTeX symbols.

Run mptopdf keyhole.mp, which will produce a file with name keyhole-1.pdf.

Now the LaTeX test file:

\documentclass{article}
\usepackage{amsmath}
\usepackage{graphicx}

\DeclareRobustCommand{\keyhole}{%
\mathrel{\text{\includegraphics[height=\fontcharht\fontX]{keyhole-1}}}%
}

\begin{document}

$A\keyhole B_{\keyhole}$

\end{document}
`

It would be possible to define different figures with different line thickness for the smaller sizes.