# how to draw a little crown above a math symbol

I'd like to have a command \crown that would draw a little crown above a symbol, e.g. $\crown x$ should show an $x$ with a little crown over it. I know I can use the accents package to declare any symbol as an accent, but how do I create a compatible symbol?

• stackengine package, perhaps? Which package provides a crown at all? – user31729 Jun 1 '16 at 19:48

Go out to the web and find a crown image that suits, such as http://images.clipartpanda.com/queen-crown-clipart-black-and-white-black-crown-clipart-nTE8GkyTA.gif. If it is not the proper format (this is a gif), use your graphics software (e.g., MSPaint) to save it as a jpeg.

MATH MODE version

Then, just patch its name into the \crownset macro definition below, adjusting the leading \kern if the image had asymmetric horizontal space about it. Other parameters that can be tweaked include the overset gap, currently set to .7pt, and image width, currently set to 1.2\LMex.

The stack is set up to ignore the width of the crown during the typeset, so that \crownset is does not adversely affect the horizontal spacing.

EDITED to account for slant of math font.

\documentclass{article}
\usepackage{stackengine,graphicx,scalerel}
\usepackage[nopar]{lipsum}
\newcommand\crownset[1]{\ensurestackMath{\ThisStyle{%
\setbox0=\hbox{$\ThisStyle#1$}%
\stackengine{.7pt}{\SavedStyle#1}{\kern\dimexpr-.1\LMex+.25\ht0\relax%
\includegraphics[width=1.2\LMex]%
{queen-crown-clipart-black-and-white-black-crown-clipart-nTE8GkyTA}}%
{O}{c}{F}{T}{S}}}}
\begin{document}
$y = m \crownset x + \frac{\crownset{f}}{\crownset y^2}$
$\scriptstyle y = m \crownset x + \frac{\crownset{f}}{\crownset y^2}$
$\scriptscriptstyle y = m \crownset x + \frac{\crownset{f}}{\crownset y^2}$
\end{document}


If I don't like that crown, just find another, such as https://openclipart.org/image/2400px/svg_to_png/242116/Royal-Crown-Silhouette.png and substitute the file name into the macro:

TEXT MODE version

The stack is set up to ignore the width of the crown during the typeset, so that \crownset is does not adversely affect the kerning of the letter i.

The text version is also \smashed to avoid affecting the line spacing.

\documentclass{article}
\usepackage{stackengine,graphicx}
\usepackage[nopar]{lipsum}
\newcommand\crownset[1]{\stackengine{.3pt}{#1}{\kern-.07em%
\smash{\includegraphics[width=0.5em]%
{queen-crown-clipart-black-and-white-black-crown-clipart-nTE8GkyTA}}}%
{O}{c}{F}{T}{S}}
\begin{document}
\lipsum[1]
\crownset A new d\crownset ay \crownset is dawning.
\lipsum[2]
\end{document}


• A royal post ;-) (Actually, I would not use it, however :D) – user31729 Jun 2 '16 at 19:59
• @ChristianHupfer Perhaps a royal flush, then? – Steven B. Segletes Jun 2 '16 at 20:07
• Rather a fit of typographical pain (;-) -- not the solution itself, of course. Sadly, your solution is underrated. I just glued a few lines together and got of bunch of upvotes for basically nothing... – user31729 Jun 2 '16 at 20:09
• @JPi There's an old expression, "if the only tool in your toolbox is a hammer, pretty soon every problem starts looking like a nail." And since I wrote stackengine, you would not be the first to comment that it may figure over-prominently in my toolbox. – Steven B. Segletes Jun 3 '16 at 10:03
• It would be better to use a vector graphic than a bitmap, though? – Davislor Dec 24 '18 at 15:14

A very primitive way, with \symking from skak package by Ulrike Fischer (symbolizing a 'crown') and \overset (Thanks to Ulrike Fischer following information: the fonts for \symking are provided by the chessfss package actually, which is loaded by skak)

\documentclass{article}
\usepackage{amsmath}
\usepackage{skak}
\usepackage{accents}

\newcommand{\crown}[1]{\overset{\symking}{#1}}
\newcommand{\xcrown}[1]{\accentset{\symking}{#1}}

\begin{document}

$\crown{x}$
$\xcrown{x}$

\end{document}


• Ingenious to think about the skak package! – JPi Jun 1 '16 at 20:00
• @JPi: The only package that I remember that has something like a crown – user31729 Jun 1 '16 at 20:00
• Right: the reason I asked the question is that I couldn't. – JPi Jun 1 '16 at 20:03
• @JPi: well, there might be others, basically any chess-related package should provide such symbols. – user31729 Jun 1 '16 at 20:05
• actually it is not skak that provides the symbol but chessfss (loaded by skak). – Ulrike Fischer Jun 1 '16 at 20:34