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?
2 Answers
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}
-
1
-
-
1
-
@JPi: well, there might be others, basically any chess-related package should provide such symbols. – Jun 01 '16 at 20:05
-
@http://tex.stackexchange.com/users/31729/christian-hupfer: Ok. I'll accept it: works well once paired with
\accentsetfrom the accents package. – JPi Jun 01 '16 at 20:10 -
5actually it is not skak that provides the symbol but chessfss (loaded by skak). – Ulrike Fischer Jun 01 '16 at 20:34
-
You could probably also use a queen instead of a king, if you want something more Eastern and less... St. Edwardsy. – Kevin Jun 02 '16 at 06:04
-
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}
- 237,551
-
-
-
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
-
-
@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 -
-
1




stackenginepackage, perhaps? Which package provides a crown at all? – Jun 01 '16 at 19:48