Why Can’t I Use \DeclareMathOperator{\H}{\mathbb H}?
At a glance
- 1. Check the command name
LaTeX already defines \H as an accent command, so it cannot be declared again as a new math operator.
- 2. Choose a fresh name
Use a name such as \HH for the blackboard-bold symbol, or \Hom for a named mathematical operator.
- 3. Match the command to its role
Use \newcommand for a symbol; use \DeclareMathOperator for names that should behave like operators.
The problem is a command-name conflict: \H is already a LaTeX command for placing a Hungarian double-acute accent over a letter. \DeclareMathOperator is intended to define a new command, so declaring \H again produces an error.
For a blackboard-bold H, define a different command name. Also, use \DeclareMathOperator only when you want operator spacing; \mathbb{H} is usually a symbol, not an operator.
Why \H is unavailable
LaTeX already assigns \H a meaning. For example, \H{o} produces an accented letter. Since \DeclareMathOperator does not silently overwrite commands that already exist, this declaration conflicts:
\DeclareMathOperator{\H}{\mathbb{H}}
The issue is the command name, not the \mathbb command or the braces around H. A command name can be reused only by deliberately replacing its existing definition, but changing \H would remove its accent function and could also break commands in packages or documents that rely on it. It is better to choose a new name.
Define the blackboard-bold symbol
Use \newcommand for a symbol that simply displays \mathbb{H}:
\documentclass{article}
\usepackage{amsfonts} % provides \mathbb
\newcommand{\HH}{\mathbb{H}}
\begin{document}
Let $H$ be a group and consider the set $\HH$.
\end{document}
This is a complete minimal example. The amsfonts package provides \mathbb; amssymb also loads the relevant fonts and symbols. The command \HH is just a convenient shorthand, and the braces in \mathbb{H} make clear which character is being typeset.
You can choose another unused name, such as \mathbbH or \Hbb. Pick one that is easy to recognize and unlikely to conflict with packages used in your document. \newcommand will report an error if your chosen name is already defined, which helps catch conflicts instead of silently changing existing behavior.
When \DeclareMathOperator is appropriate
A named operator should have the spacing of standard operators such as \sin, \log, or \det. The amsmath command \DeclareMathOperator creates that kind of math command:
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\Hom}{Hom}
\begin{document}
$\Hom(G,H)$
\end{document}
Here, \Hom is set upright and receives operator spacing. By contrast, \mathbb{H} is a mathematical symbol; it normally belongs in an ordinary symbol command such as \HH. Wrapping a symbol in an operator declaration can give it operator spacing and behavior that are not intended.
If you specifically want a blackboard-bold character to act as an operator, give the declaration a fresh name, for example \DeclareMathOperator{\HOp}{\mathbb{H}}. Do this only when operator-style spacing is actually appropriate. The asterisk form, \DeclareMathOperator*, is for operators that should place limits above and below in display math, as \lim does.
Common mistakes
- Trying another declaration command with the same name:
\newcommand{\H}{...}also fails because\Halready exists. Changing the declaration command does not remove the name conflict. - Using
\renewcommandjust to suppress the error: this replaces the accent command. It may cause unrelated text or packages to behave incorrectly. - Treating every math symbol as an operator: operator spacing is useful for functions such as
Hom; a set or number-field symbol usually should not receive it. - Forgetting the font package: if
\mathbbis undefined, loadamsfontsoramssymbin the preamble.
Keep the built-in \H for accented text, define a fresh shorthand such as \HH for the blackboard-bold symbol, and use \DeclareMathOperator for genuine named operators.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.