I am trying to define the following new command:

\newcommand{\kernel}[2]{k\left( #1, #2 \right)}

which when implemented via


yields k(.,Y) (not sure how to reproduce the \cdot here)

which works, however I would like to set a default for the first argument to be \cdot, and I tried to do it via the following:

\newcommand{\kernel}[2][\cdot]{k\left( #1, #2 \right)}

however if I implement it via


it gives k(.,)Y and not k(.,Y)!!!

This seems like a weird bug and I was wondering if anyone knew how to fix it, I tried using xparse instead to define the command but I got the same bug. Thanks in advance!

  • 5
    Since it is an optional argument, you would say $\kernel[]{Y}$ with square brackets around the optional (null) argument. – Steven B. Segletes Mar 28 '17 at 10:16
  • 1
    This is no bug but wrong usage ;-) – user31729 Mar 28 '17 at 10:20
  • Isn't there already a \ker command that indicates the kernel of a vector space? – user31729 Mar 28 '17 at 10:27

The given definition of the \kernel command is ok, but the calling is wrong. [2][\cdot] means that the first argument is optional and has be to called with \kernel[foo]{Y},i.e. [...] indicates the optional argument.

In the code below I show an xparse version, also replacing k with a operator (expanding to k) and removing the \left(...\right) pair.








enter image description here

  • 1
    I usually give some room to the dot, with \,\cdot or even \,\cdot\,. – Manuel Mar 28 '17 at 10:45
  • @Manuel: That depends on personal preferences. The issue was the wrong usage of the command, I only improved it somewhat :-) – user31729 Mar 28 '17 at 12:15

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.