3

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
\begin{equation}
    \log(a/b)
\end{equation}
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!

5
  • 1
    It should be $\bm{\log(a/b)}$, if you really want that. But I'd not be surprised if physics chokes with it.
    – egreg
    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
  • 1
    Why insisting on using \bm outside math mode?
    – egreg
    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
3

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
\begin{equation}
    \log(a/b)
\end{equation}
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.

2
  • 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.
    – egreg
    Jul 9 '20 at 12:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.