How to get \^{\i} working in math enviroment

You can access the dotless version of i and j in math mode using \imath and \jmath.

\documentclass{article}
\begin{document}
$\hat{\imath}$
$\hat{\jmath}$
\end{document}

enter image description here


You can set up a similar tool to \^:

\documentclass{article}
\usepackage{amsmath}
\usepackage{xparse}
\usepackage{letltxmacro}

\ExplSyntaxOn
\LetLtxMacro \egreg_hat:n \hat % save the original command

\RenewDocumentCommand{\hat}{m}
 {
  \str_case_e:nnF { \tl_trim_spaces:n { #1 } }
   {
    {i}{\egreg_hat:n { \imath }}
    {j}{\egreg_hat:n { \jmath }}
   }
   { \egreg_hat:n { #1 } }
 }
\ExplSyntaxOff

\begin{document}

$\hat{a}+\hat{i}+\hat{j}$

\end{document}

enter image description here


You can always use \text{} to escape math mode, provided by the amsmath package. So the solution would be \^{\i} when in text mode, and \text{\^{\i}} when in math mode.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
$f(t) = \sin(\text{\^{\i}} \cdot t)$.
\end{document}

enter image description here