[Tex/LaTex] New DeclareMathOperator


In my MWE below, I wanted the create a shortcut for some operators. How can I get the \DeclareMathOperator command to show up like the conventional way of using the actual command $\mathbf{z}(k)$ ?

Also, is there an even shorter way to get this command, like say for example just type \z instead of $\z$ ?

Here is my code:

\usepackage{amsmath,amsfonts,amssymb,amsthm, bm} 


How do I get this Math operator $\z$ to show like this $\mathbf{z}(k)$?

Best Answer

Quoting from this question, DeclareMathOperator is designed to create commands that should typeset operator names such as sin and lim. The default font for these quantities is upright. If you want part of the operator name to be slanted (in the way variables are usually typeset), you have to specify this explicitly:


On the other hand, I would guess that what you actually want is that only the 'z' itself is the operator name:


The part in parenthesis should be the argument to this operator. If you frequently use the same argument, you could define a short hand for this, using \newcommand:


Concerning your second question, if you encapsulate your definition with \ensuremath, you can use your command both within or outside of math environments:


With the last definition, both $\zk$ and \zk{} should give the same result.

Related Question