# Why are certain mathematics operators not defined and how do I replicate them?

I noticed that while \ker renders correctly as the "kernel" operator in Linear Algebra, the corresponding \im for the "image" is not defined (I tried everything that could possibly be an abbreviation for "image") nor is "rank" given a command.

Can I get these operators from some kind of 'math add-on' package? And if not, how should I typeset operators correctly? I tried \text{im}A but this didn't put any space, so I ended up doing \text{im}\, A - is that the right amount of spacing for an operator?

EDIT: Also, what's the difference between \text{stuff} and \mathrm{text}?

• Use \DeclareMathOperator{}{} with the amsmath package. – Peter Grill Apr 30 '14 at 2:55
• What do I put in the two braces? – user50612 Apr 30 '14 at 2:58
• See tex.stackexchange.com/q/671/86 for the main part of the question. – Andrew Stacey Apr 30 '14 at 5:08
• Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. A suggestion: Do us a favour and change your username to something more telling than "user1234". – Martin Schröder May 1 '14 at 16:33

You can use \DeclareMathOperator to declare other math operators:

There are way too many to have them all defined so \DeclareMathOperator is provided to allow one to define their own.

## Code:

\documentclass{article}

\usepackage{amsmath}

\DeclareMathOperator{\im}{im}

\begin{document}
$\ker A \quad \im B$
\end{document}

• Ok so the first brace is the code, and the second is what it will write? So I could do a shortcut like \DeclareMathOperator{\i}{image} and have it write out "image" is that correct? – user50612 Apr 30 '14 at 2:59
• Can I make a package with a bunch of those "declare operators" that I can use in all my papers? – user50612 Apr 30 '14 at 3:02
• I'd recommend using longer names over shorter names so as to not overwrite any existing macros. Even if you check that a particular macro names is not currently in use, it may be used by a package that you decide to use in the future. So \Image would be preferable over \i (which already has a meaning). And yes you can put all these in one .sty file and just include it as you do other packages. – Peter Grill Apr 30 '14 at 3:03
• Ok got it, cheers! – user50612 Apr 30 '14 at 3:06