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

My question is a like the one here: only with different symbol.

With typing: $\^{\i}$ i want to get a get a i with a ^ (replacing the dot) on its head.

So far, so good. Means it works (i get the symbol i wish to get) but TeXstudio (Version 2.12.10 (git 2.12.10)) gives me two warnings also:

Command \^ invalid in math mode

and

Command \i invalid in math mode

The command \hat{i} gives me an i with a ^ ontop. That is not excactly what i want.

The solution with $\o$ replaced by \varnothing or \Emptyset seams to be the same, well maybe i'm just searching for the right word for my symbol in question?

Any suggestions?

Update 1 after getting a solution form @Henri Menke

(On the left side of the equation)
The left one is the result of \hat{\imath} result, \cdot, the right one it the result of \^{\i}

With other words:

Lets assume that \hat{\imath} is indeed the right symbol, than i have to write $$\hat{\imath}$$ (with math enviroment) every time i need to use it in my text for reference?

Update 2 I knew that link before asking my question but it wasn't helpfull in my case. Maybe have a look here, for looking up other unknown symbols if you have a "similar" question (Please credit him if it helps you)

• Use \hat{\imath}. – Henri Menke Aug 5 '18 at 4:27
• Please clarify what you need to obtain. Is it an upright or a slanted version of the dotless letter “i” with a hat on top? And, will you be using this symbol in text mode or in math mode? – Mico Aug 5 '18 at 5:49
• @Mico I think it should be itallic like every other variable in every equation too. But i have to write some text about the variables i'm using so i need to write it sometimes in my text too With the same look. – user167193 Aug 5 '18 at 6:00
• @user167193 - If it's a symbol for a math variable, you should be using (math) italics, i.e., you should be using hat{\imath}. Obviously, this requires the use of math mode. Henri's answer is correct. – Mico Aug 5 '18 at 6:09
• @Mico Thank you. I will if i can. :-) Good night. – user167193 Aug 5 '18 at 6:13

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}


• well yes, maybe you are right. I tried you solution. I get a slighly different looking i with a ^ head than before. is that correct / ok ? I will try to add a picture and a update to my question. – user167193 Aug 5 '18 at 4:41
• If this is the way to go to get the itallic version of the i with the ^ as head than i will accept your answer tomorrow. :) – user167193 Aug 5 '18 at 6:07

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}


• I think this is a little bit to much for me (my purpose) but maybe others can work with it. – user167193 Aug 5 '18 at 16:08

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}


• Atleast this would supress the warning. You are right. But even in your example the roman i with the ^ head ... I don't know maybe if it represents a constant or something like that. But for my usage i'm happy with @Henri's answer. – user167193 Aug 5 '18 at 15:59