I would like to write a hat over just an empty space, like \hat{ }
. My problem is that I need it to be at a certain height, which happens to be higher that the standard height I get with the previous command. I tried to raise the hat using \vspace{}
like this: \hat{\vspace{.1cm}}
(changing the .1cm
to different values), but got no result; the hat remains at the same height. So I would like to know of an alternative way of doing what I need.
2 Answers
Here I put \hat
over a hard space, otherwise it takes up no width. Then, I can use \raisebox
to lift it higher.
\documentclass{article}
\begin{document}
$a \hat{~} b \raisebox{2pt}{$\hat{~}$} c$
\end{document}
To obey the smaller mathstyles, I make the macro \highhat[]
that can take a real number as an optional argument, specifying the number of "local-mathstyle points" to raise the hat (default 2\LMpt
).
\documentclass{article}
\usepackage{scalerel}
\newcommand\highhat[1][2]{\ThisStyle{\raisebox{#1\LMpt}{$\SavedStyle\hat{~}$}}}
\begin{document}
$a \hat{~} b \highhat c \highhat[4] d$
$\scriptstyle a \hat{~} b \highhat c \highhat[4] d$
$\scriptscriptstyle a \hat{~} b \highhat c \highhat[4] d$
\end{document}
One option that might help you is to place the hat over a phantom
character. The phantom
character will not be shown, but still takes up space.
\documentclass{article}
\begin{document}
$\hat{~} \hat{b} \hat{\phantom{b}}$
\end{document}