# Normal \hat along with realhats package?

The realhats package changes the \hat{} command, such that LaTeX places a random, funny hat on top of the variable, instead of the normal "^"-shape. I would like to use the package to get funny hats in a few places, but need the normal \hat{} to work unchanged.

Can this be easily achieved?

edit: see the package documentation for a visual example of what the package does.

• I don't know how to explain it better than the package documentation does, but I've now linked that for reference. May 23 at 9:36

The \Hat command when amsmath is loaded is defined as an alias to \hat. You can reuse this command to produce the standard \hat accent.

\documentclass{article}
\usepackage{amsmath}

\RenewCommandCopy{\Hat}{\hat}
\usepackage{realhats}

\begin{document}

$\hat{a}+\Hat{a}$

\end{document}


Here's how you can have \hat to typeset the standard one and \realhat the “real” one.

\documentclass{article}
\usepackage{amsmath}

\NewCommandCopy{\HAT}{\hat}
\usepackage{realhats}
\NewCommandCopy{\realhat}{\hat}
\RenewCommandCopy{\hat}{\HAT}

\begin{document}

$\realhat{a}+\hat{a}$

\end{document}


Comment
In my opinion, the realhats package should define \realhat and offer an option, say override, to replace \hat with \realhat.

• Thanks a lot. That is a good step of the way at least. Is there a further hack to flip the two? Just to avoid having to change 100s of equations already typeset with \hat? May 23 at 9:46
• @ChristofferØstfeldt Added. May 23 at 9:53
• What is the difference between this \RenewCommandCopy solution and just using \let\Hat=\hat? May 23 at 10:30
• I've marked the answer as accepted. Only thing left to add, is that it requires a new-ish version of LaTeX, as the commands used are not available in, e.g., TeX live 2019 (the version installed on Ubuntu 20.04, for example). May 23 at 10:43
• @ChristofferØstfeldt For older LaTeX you can use \LetLtxMacro from the letltxmacro package. May 23 at 11:01