Very often I have to write \text{im}(f), to denote the image of f, if I try to write, \im f, then it generates the Imaginary notation which I do not want, if I write im f then it looks awful. Is there a way to tell my editor to recognize \im to generate \text{im} so that I do not need to write it every time?
2 Answers
Why not create a new macro? You could do
\usepackage{amsmath}
and then
\DeclareMathOperator\Img{Im}
after which \Img creates the notation that you want, with correct spacing.
You can use
\newcommand{\im}{\operatorname{Im}}
or go with amsmath and use @Ian_Thompson's solution, which is my favorite.
These two solutions give a proper mathematical spacing but select a font automatically.
If math spacing is not required, use
\newcommand{\im}{\mathrm{Im}}
To get math spacing with font selection use
\newcommand{\im}{\mathop{\mathrm{im}}}
\textto mark a mathematical construction! It is for textual comments only! This is a very common mistake. Why so bad?\textit{$\text{im}(f)$}gives an italicimwhich is not correct. Ians solution is the proper one.\textswitch to italics inside theorems and definitions).\text{Im}does not get the proper spacing either (Ians solution does). I see this error a lot among students. The two most common mistakes is (1) the one you do here, and (2)X_{\text{max}}which suffer from the same problem. Here\mathrmor even\textupis more correct.