# operator name for kernel

I'm trying to define \newcommand{\ker}{\operatorname{ker}} just after \begin{document} in order to have a nice way to write the kernel of an application but the command is ignored and I don't know why since I put \usepackage{amsmath}.

-

The amsmath package offers \ker:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

$X=\ker f.$

\end{document}


If you want an upper-cased variant, you can use \DeclareMathOperator:

\documentclass{article}
\usepackage{amsmath}

\DeclareMathOperator{\Ker}{Ker}

\begin{document}

$X=\Ker f.$

\end{document}


The syntax for \DeclareMathOperator is

\DeclareMathOperator{\xxx}{yyy}


and using \xxx in the document body will produce yyy in the proper font and will automatically add proper spacing on either side when necessary.

For new operators with subscripts and superscripts placed in "limits" position above and below, use the * form:

\DeclareMathOperator*{\xxx}{yyy}

-
Suppose that I want to use the same command \ker for Ker. What do you suggest? I did \DeclareMathOperator{\kker}{Ker}\renewcommand{\ker}{\kker} but I don't know if it is the more elegant way. –  Sigur Apr 3 '14 at 0:58
@Sigur yes, that's an option, but I'd prefer to store the original definition, just in case. I'd use something like \makeatletter \let\oldker\ker \def\ker{\mathop{\operator@font Ker}\nolimits} \makeatother; in this way, \ker produces "Ker" and \oldker preserves the original definition. –  Gonzalo Medina Apr 3 '14 at 1:59
Nice! I'll update my code. Thanks. –  Sigur Apr 3 '14 at 2:10