# special characters in equation [closed]

I need to use a special character {\i} in a equation, but it is escaped inside the block although it appear clearly in text. I have tried \usepackage[utf8]{inputenc} and \usepackage[T1]{fontenc} packages but it doesn't work for equation block, could you help me please? Thank you in advance

## closed as off-topic by Andrew Swann, Kurt, user36296, Stefan Pinnow, SebastianoNov 22 '18 at 11:54

• This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• Welcome to TeX.SE. For me, \documentclass{article} \begin{document} \i $\i$ \end{document} shows that there is no difference with \i in math mode or text mode. Please use something like this to create a MWE that that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. This will also help to clarify exactly what the issue is. – Peter Grill Nov 21 '18 at 6:52
• @PeterGrill When I compile your MWE with pdflatex, I do get a warning LaTeX Warning: Command \i invalid in math mode on input line 3.. However, the output is equal inside and outside math environments, as you say. – marmot Nov 21 '18 at 6:56
• Does in \documentclass{article} \usepackage{amsmath} \begin{document} \i $\text{\i}\imath$ \end{document} either \text{\i} or \imath give you the desired output? – marmot Nov 21 '18 at 6:58
• @marmot: What?? Are we supposed to actually look at the warnings? :-). I didn't notice it as the question seemed to imply that the problem was in how they were displayed. – Peter Grill Nov 21 '18 at 7:02
• I'm voting to close this question as off-topic because it is solved by comments – Kurt Nov 22 '18 at 11:18

Don't know if I understood the question properly, however, this is what I understood

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

\makeatletter
% \user@i is the same as \i
\LetLtxMacro\user@i\i
\let\i\relax % remove the definition for \i
\DeclareRobustCommand{\i}{%
\TextOrMath{\user@i}{\text{\normalfont\user@i}}%
}
\makeatother

\begin{document}

\i

i

$$\i\ i$$

\end{document}


The code has been taken and slightly modified from the first answer to this question: How to redefine a command to contain itself in it by maintaining it's syntax unchanged

• Thank you very much firstly, yes you understood me perfectly :) in your file it seems working well but maybe bacause of my class file (.cls) the {\i} character displays similar to beta letter. But i solve the problem with \textnormal{\i} or \textrm{\i} command in equation. Thanks again – Yelda Nov 22 '18 at 7:51