9

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}.

12

The amsmath package offers \ker:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
X=\ker f.
\]

\end{document}

enter image description here

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}

enter image description here

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}
  • 1
    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
  • 1
    @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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.