Tx · LaTeX & TikZ

How to Fix “Extended mathchar used as mathchar” with \bm

Published By the 9to5Science editorial team

At a glance

  1. 1. Check the packages

    If your document loads unicode-math and bm, the combination is the likely cause.

  2. 2. Remove bm

    Delete \usepackage{bm}; do not use \bm for bold symbols in a unicode-math document.

  3. 3. Use math alphabets

    Choose commands such as \symbf or \symbfit for the bold style you need.

  4. 4. Compile and test

    Compile with XeLaTeX or LuaLaTeX, then reduce any remaining error to a minimal example.

The error “Extended mathchar used as mathchar” commonly appears when a document combines unicode-math with the older bm package. unicode-math uses Unicode math fonts and its own commands for mathematical alphabets; bm relies on older math-character mechanisms that do not work reliably with that system.

If your preamble contains both \usepackage{unicode-math} and \usepackage{bm}, remove the bm package and replace its \bm{...} commands with the appropriate unicode-math command. The examples below show the usual replacements.

Why the packages conflict

The bm package was designed to make a wide range of mathematical material bold in traditional LaTeX math-font setups. unicode-math, by contrast, provides Unicode mathematical alphabets and defines commands for selecting them. The two packages use different approaches to selecting and transforming math glyphs. As a result, applying \bm to a Unicode math character can trigger the extended-math-character error.

The issue is not usually a problem with XeTeX or MiKTeX itself. XeLaTeX is a valid engine for unicode-math; the key is to use the package’s own bold commands rather than loading bm alongside it.

Replace \bm with a Unicode math command

For bold upright symbols, use \symbf. For bold italic symbols, use \symbfit. Which style is appropriate depends on your notation: for example, vectors are often set in bold italic, while other symbols may be bold upright.

Intended styleCommand
Bold upright\symbf{...}
Bold italic\symbfit{...}
Bold sans serif\symbfsf{...}
Bold sans-serif italic\symbfsfit{...}

These commands select mathematical alphabets; they are not guaranteed to make every arbitrary expression bold in exactly the same way as \bm. For an expression containing several kinds of symbols, choose the commands that match the symbols and notation you want.

Worked example

This minimal document uses unicode-math without bm. Compile it with XeLaTeX or LuaLaTeX:

\documentclass{article}
\usepackage{unicode-math}
\setmathfont{Latin Modern Math}

\begin{document}

Bold upright: $\symbf{A}$ and $\symbf{\alpha}$.\\
Bold italic: $\symbfit{A}$ and $\symbfit{\alpha}$.

\end{document}

Here, \usepackage{unicode-math} loads the Unicode math support, and \setmathfont selects a math font. Latin Modern Math is a commonly available Unicode math font. The two lines demonstrate upright and italic bold forms; neither requires \bm.

For example, if your original source contains $\bm{\alpha}$ and you want bold italic alpha, change it to $\symbfit{\alpha}$. If you want upright bold alpha, use $\symbf{\alpha}$ instead.

Check the preamble and engine

  1. Search the preamble for \usepackage{bm} and remove it when you use unicode-math.
  2. Replace each \bm{...} with an appropriate \sym... command, checking whether upright or italic bold is intended.
  3. Confirm that the document is compiled with XeLaTeX or LuaLaTeX. unicode-math is not intended for pdfLaTeX.
  4. Recompile and check the first error in the log. A later error may only be a consequence of the first one.

If the message remains, make a minimal test file containing only the document class, relevant package lines, math font selection, and the failing expression. Check for another package or command definition that changes math alphabets. Updating the TeX distribution and unicode-math may help if the minimal example still fails, but reinstalling MiKTeX is not the first fix to try.

Common mistakes

  • Keeping bm loaded after replacing its commands. Remove the package too; an unused bm load can still cause compatibility trouble.
  • Using the wrong bold style. \symbf and \symbfit differ in upright versus italic appearance. Match the convention used in your document.
  • Changing the engine to pdfLaTeX. That does not solve a unicode-math setup; use XeLaTeX or LuaLaTeX.
  • Assuming every \bm expression has a one-command replacement. \bm may bold mixed expressions as a whole. With unicode-math, select the desired alphabet for the symbols involved, and test complex notation carefully.

If you are not using unicode-math, bm can still be useful in a traditional LaTeX math-font setup. The recommendation to avoid it here applies specifically to documents using unicode-math.

References

  1. The unicode-math package documentation
  2. The bm package documentation

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.