12

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?

JPi
  • 13,595
  • 3
    stackengine package, perhaps? Which package provides a crown at all? –  Jun 01 '16 at 19:48

2 Answers2

22

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}

enter image description here

8

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}

enter image description here

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:

enter image description here

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}

enter image description here

  • A royal post ;-) (Actually, I would not use it, however :D) –  Jun 02 '16 at 19:59
  • @ChristianHupfer Perhaps a royal flush, then? – Steven B. Segletes Jun 02 '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... –  Jun 02 '16 at 20:09
  • @ChristianHupfer Regarding: "I just glued a few lines together", that is what they call "elegant"! – Steven B. Segletes Jun 02 '16 at 20:21
  • Wow, that is pretty!! – JPi Jun 03 '16 at 01:31
  • @Steven B. Segletes: Why are you using stackengine instead of the accents package? Stackengine looks more impressive, but placement seems better with the accents package, e.g. with the letter $f$. I used your crown with \newcommand{\sscrown}[1]{\accentset{\includegraphics[width=1.2ex]{crown}}{#1}} which appears to work well. – JPi Jun 03 '16 at 01:51
  • 1
    @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 03 '16 at 10:03
  • @JPi Of course, one can account for the letter slant with stackengine, as well, by modifying the horizontal kern as a function of the letter height, as my EDIT reveals. – Steven B. Segletes Jun 03 '16 at 10:21
  • @Steven B. Segletes: Ah great, thanks! (it was curiosity, not criticism) – JPi Jun 03 '16 at 20:43
  • 1
    It would be better to use a vector graphic than a bitmap, though? – Davislor Dec 24 '18 at 15:14