# A custom “letter” in text mode

I am trying to typeset a letter x (in both lower- and uppercase) that has a small circle overlaid exactly onto the (perceived) middle of the character. My current best effort is x\llap{$\circ$}, but not only is the resulting circle somewhat bigger than I want, it is visibly not quite centered on the x.

I am using XeLaTeX, if it helps. I have tried looking for unicode combining characters that would do what I want, but the only two candidates I saw (U+208D "COMBINING RING OVERLAY" and U+20DD "COMBINING ENCLOSING CIRCLE") were both very large, and also shared the failure of centering.

Ideally, I would be able to have a simple command that produces this "custom character", because I will need to use it many times.

EDIT: I've decided to use the stackengine-based solution, but all the options look good. Thanks!

EDIT 2: I've switched to the tikz-based solution, because it generalizes much better.

With tikz

\documentclass{article}
\usepackage{tikz}
\newcommand{\circledx}{%
\begin{tikzpicture}
\node[inner sep=0pt,outer sep=0pt] (a) {x};
\draw (a.center) circle (0.15ex);
\end{tikzpicture}
}
\newcommand{\circledX}{%
\begin{tikzpicture}
\node[inner sep=0pt,outer sep=0pt] (a) {X};
\draw (a.center) circle (0.2ex);
\end{tikzpicture}
}
\begin{document}
\circledx and \circledX
\end{document}


There is a special command for that in the stackengine package:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[svgnames]{xcolor}
\usepackage{amsmath}
\usepackage{stackengine}

\begin{document}

\stackinset{c}{}{c}{}{\color{red}$\scriptstyle\circ$}{\color{ForestGreen}$x$} \quad \stackinset{c}{}{c}{}{\color{red}$\scriptstyle\circ$}{\color{ForestGreen}x}

\stackinset{c}{}{c}{}{\color{red}$\scriptscriptstyle\circ$}{\color{ForestGreen}$x$}\quad \stackinset{c}{}{c}{}{\color{red}$\scriptscriptstyle\circ$}{\color{ForestGreen}X}

\end{document}


• Cool! This seems to be just as good as the other options. – Ptharien's Flame May 11 '15 at 2:57

Not with tikz

\documentclass{scrartcl}
\usepackage{graphicx}

\makeatletter
\def\cx
{{\ooalign{x\cr
\hidewidth\raisebox{.2ex}{$\m@th\scriptscriptstyle\circ$}\kern.01em \hidewidth\cr}}}
\def\cX
{{\ooalign{X\cr
\hidewidth\raisebox{.4ex}{$\m@th\scriptstyle\circ$}\kern.01em \hidewidth\cr}}}
\makeatother

\begin{document}
\cx\ and \cX
\end{document}


This code places the original ring accent (which is smaller in Computer Modern and you might prefer).

\makeatletter
\def\cx
{{\ooalign{x\cr
\hidewidth\raisebox{-.95ex}{\r{}}\hidewidth\cr}}}
\def\cX
{{\ooalign{X\cr
\hidewidth\raisebox{-.62ex}{\r{}}\kern.01em \hidewidth\cr}}}
\makeatother

• This is also good, although the circle is a little big still; nonetheless, I'll have to keep this approach in mind. – Ptharien's Flame May 11 '15 at 1:16
• You can always scale it down \scalebox{.5}{..}. In any case, if it's too small, is it noticeable? It looks more like a dot/bullet than a circle. – Manuel May 11 '15 at 1:17
• I'm using a font with very thin lines, so it remains visibly a circle at tiny proportions. Thanks for \scalebox, though! – Ptharien's Flame May 11 '15 at 1:19
• I added another alternative with original ring accent \r{..}. The basic idea is that you can use whatever symbol you want. – Manuel May 11 '15 at 1:27