8

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?

mystery symbol

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

  • 2
    Welcome to TeX.SX! Does the symbol have a name? – Bobyandbob Aug 1 '17 at 9:49
  • 1
    @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
  • 10
    Is this symbol your ad hoc invention, or did you find it in some math publication? What should it denote? – jknappen 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
20

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}

enter image description here

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}

enter image description here

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}

enter image description here

18

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\font`X]{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.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.