Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 8 down vote accepted

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}
share|improve this answer
    
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 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 at 1:59
    
Nice! I'll update my code. Thanks. –  Sigur Apr 3 at 2:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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