Fatal error when using bold math and physics

I have a problem where writing \log in bold math \bm{$\log$} is resulting in a fatal error. I am using a multitude of packages, but I've narrowed it down to the physics package.

I get 10 errors when compiling a document like this:

\documentclass{article}
\usepackage{physics}
\usepackage{bm}

\begin{document}
It works fine in regular math mode
$$\log(a/b)$$
But when writing it in bold math, it doesn't work \bm{$\log(a/b)$} when physics is loaded.

\end{document}


Hopefully someone know how I can fix this, I can't really decode the error messages. Thanks in advance!

• It should be $\bm{\log(a/b)}$, if you really want that. But I'd not be surprised if physics chokes with it. Jul 9 '20 at 12:10
• Right now I've just used \textbf{log}\bm{$(k_X/k_H)$}, but I'd like to see if there is another solution Jul 9 '20 at 12:16
• Why insisting on using \bm outside math mode? Jul 9 '20 at 12:18
• @egreg Sadly $\bm{\log(a/b)}$ doesn't work either, still produces a fatal error Jul 9 '20 at 12:19
• @egreg I am convinced that that is the correct use of it, but I might be wrong. It doesn't produce any errors when I do it like that Jul 9 '20 at 12:19

Plainly said, physics and bm are not compatible with each other (and the blame is on the former).

\documentclass{article}
\usepackage{physics}
\usepackage{bm}

\DeclareRobustCommand{\allbm}[1]{\begingroup\boldmath#1\endgroup}

\begin{document}

It works fine in regular math mode
$$\log(a/b)$$
But when writing it in bold math, it doesn't work \allbm{$\log(a/b)$} when physics is loaded.

\end{document}


Some comments: while \bm{$<formula>$} seems to work, it is wrong. It should be

$\bm{<formula>}$


On the other hand, physics redefines \log to do a complicated (and mostly useless) series of operations in order to automatically size parentheses. This makes the thing very fragile.

I'd avoid the package: in my opinion it offers nothing very advantageous.

• Thanks, I think I've found an alternative for the physics package Jul 9 '20 at 12:28
• @ChristianP. Don't tell me it's commath, please. Jul 9 '20 at 12:32