# DeclareMathOperator in bold

Ho can I declare a math operator which will appear in bold font?

I tried the following, but it didn't work:

\DeclareMathOperator{\Div}{Div}
\newcommand{\Divxk}{\mathbf{\Div}_{X/k}}


## 3 Answers

The \mathbf around \Div does nothing, because \Div is translated internally to something like "choose the \mathrm font and typeset ‘Div’”. Math fonts don't inherit features from the context: \mathrm always corresponds to the upright text font in medium weight (or boldface) if \boldmath is in force.

You can check that

$\mathbf{\mathrm{x}}$


produces a medium weight ‘x’.

So you have to define

\DeclareMathOperator{\Div}{\mathbf{Div}}
\newcommand{\Divxk}{\Div_{X/k}}


The definition of \Div becomes “choose the \mathrm font and typeset ‘\mathbf{Div}’”, so, for the same reason as before, the boldface font will be chosen.

Try this:

\DeclareMathOperator{\Div}{\mathbf{Div}}

• That works, so you could define \DivB as a bold version of \Div for use as required, but that may not necessarily meet the OP's use case. The general question of why \mathbf{\SomeMathOperator} doesn't have the desired effect (and what to do about it) may be more interesting. – Chris H Sep 24 '13 at 14:10

An alternative approach is to use \boldsymbol:

\documentclass{article}

\usepackage{amsmath}
\DeclareMathOperator{\Div}{Div}
\newcommand{\Divxk}{\mathop{\boldsymbol{\Div}}_{X/k}}

\begin{document}
$$\Div$$

$$\Divxk$$
\end{document}

• The spacing is wrong; try $a\Divxk b$, where the operator nature is lost. It should be \mathop{\mathbf{Div}}_{X/k}. – egreg Sep 24 '13 at 14:55
• @egreg Of course! Thanks for pointing that out. Answer updated. – Andrew Swann Sep 24 '13 at 15:04