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?

  • Please do not ever use \text to 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 italic im which is not correct. Ians solution is the proper one.
    – daleif
    Jun 12, 2015 at 7:05
  • @daleif In all my time using Latex, I never had a problem that you describe. Perhaps, I am lucky, but it could just be a theoretical problem? Jun 12, 2015 at 8:33
  • 1
    You have just been lucky. Considering that most people use italics for their theorem statements, thus \text switch 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 \mathrm or even \textup is more correct.
    – daleif
    Jun 12, 2015 at 9:14

2 Answers 2


Why not create a new macro? You could do


and then


after which \Img creates the notation that you want, with correct spacing.


You can use


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


To get math spacing with font selection use


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .