[Tex/LaTex] stmaryrd and boldsymbol: avoid warnings

amsmathboldstmaryrdsymbolswarnings

Here are two examples:

1

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath}
\begin{document}
    $\boldsymbol x$
\end{document}

2

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath}
\usepackage{stmaryrd}
\begin{document}
    $\boldsymbol x$
\end{document}

As far as I can see, both versions produce the same output when compiled with pdflatex: there is a single "x" in bold italics.

However, when I compile document 2, I also get the following warning:

LaTeX Font Warning: Font shape `U/stmry/b/n' undefined
(Font)              using `U/stmry/m/n' instead on input line ….

Why do I get this warning (which seems to suggest that Latex was not able to find the right font) but correct output?

How do I avoid the warning? I need both of the following in my document:

  • bold versions of normal math symbols (something that I can easily produce without stmaryrd)
  • regular versions of some symbols that are only provided in stmaryrd

Best Answer

Internally \boldsymbol effectively uses \boldmath so sets up an entire bold math setup whatever symbols are actually used in bold, hence you get this warning.

The silence package gives an interface for filtering out various LaTeX messages so you could filter out these or in this case, stmaryrd uses

\SetSymbolFont{stmry}{bold}{U}{stmry}{b}{n}
                                     %%%

To declare that the bold math version should use the bold font (which is never declared as it doesn't exist).

So an alternative would be to tell LaTeX to use the normal font in the bold version.

I get no warnings for this:

\documentclass[a4paper,10pt]{article}
\usepackage{amsmath}

\usepackage{stmaryrd}
\SetSymbolFont{stmry}{bold}{U}{stmry}{m}{n}
                                     %%%
\begin{document}


aa
    $\boldsymbol{x}$
\end{document}
Related Question