# Conflict using \overset inside bold math

I'm trying to make a line of math symbols bold. I've been using \boldsymbol throughout my document to this end, but now I've stumbled with a problem. If I use \boldsymbol{\overset{\phi}{\to}} I get the following error code:

TeX capacity exceeded, sorry [main memory size=5000000]. If you really absolutely need more capacity, you can ask a wizard to enlarge me.

I've switched to \bm with the same result. I could always use \overset{\boldsymbol{\phi}}{\boldsymbol{\to}}}, but the problem is I have a line with loads of \overset commands, so it would be quite painful to do this every time manually.

Is there something else I can do to fix it? Thanks!

EDIT: \boldsymbol does indeed work, but \bm doesn't. Since the results aren't exactly the same with both commands, is there a way to make it work whith \bm?

• Everything works fine for me... You might want to provide a minimum working example of your problem! :/ – Vinzza Jun 20 '18 at 11:32
• @Vinzza Whooops, I'm sorry. I had the package bm loaded twice, so even when I thought I'd removed it, it was still in effect. Thanks a lot! Removing the package did solve the problem. – Hercule Poirot Jun 20 '18 at 11:45

I suggest to load bm anyhow: it's generally superior to ambsy.

In cases like these, adding a pair of braces is the solution:

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}

\begin{document}

$\bm{{\overset{\phi}{\to}}}$

$\overset{\phi}{\to}$

\end{document}


Better yet, in my opinion, is to define a command:

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}

\newcommand{\oversetbm}[2]{\overset{\bm{#1}}{\bm{#2}}}

\begin{document}

$\oversetbm{\phi}{\to}$

$\overset{\phi}{\to}$

\end{document}


The reason is quite simple: compare what you get from the following code.

\documentclass{article}
\usepackage{amsmath}
\usepackage{bm}

\newcommand{\oversetbm}[2]{\overset{\bm{#1}}{\bm{#2}}}

\begin{document}

$A\oversetbm{\phi}{\to}B$

$A\bm{{\overset{\phi}{\to}}}B$

\end{document}