# How to add overline on top of $\bm B$?

I represent a matrix in bold form throughout my paper, as $\bm B$. I need to add an overline to indicate a subtle transformation to this matrix. However the command $\overline{\bm{B}}$ does not seem to work. Dito with using $\bar$.

How to achieve a line on top of a bold matrix?

-
Maybe embrace it: $\bar{\bm B}$ or $\overline{\bm B}$ – Steven B. Segletes Mar 21 at 13:08
\bar is too short, \overline too long, in my point of view – Christian Hupfer Mar 21 at 13:09
Please show us a full working example that generates the problem behavior. For what it's worth, \documentclass{article} \usepackage{bm} \begin{document} $\overline{\bm{B}}$ \end{document} would appear to generate a line above a bold B without any problems. – Mico Mar 21 at 13:10
@Mico: Does not work for me. I shall attach the example soon. – Bravo Mar 21 at 13:13
@Bravo - An expression such as "Does not work for me" is not at all helpful. Please be more specific. – Mico Mar 21 at 13:48

After showing how \bar and \overline can be made to work by embracing the argument, I then introduce \overlinebold that scales with math style and perhaps looks better. It uses the width of the upright version of the letter, and offsets the overstoke by 3mu to account for the italics.

\documentclass{article}
\usepackage{bm}
\usepackage{scalerel}
\def\overlinebold#1{\ThisStyle{\ooalign{%
$\SavedStyle\mkern3mu\overline{\phantom{\mathrm{#1}}}$\cr $\SavedStyle\bm #1$}}}
\begin{document}
$\overline{\bm B}\quad \bar{\bm B} \quad\overlinebold{B}$

$\scriptstyle \overline{\bm J}\quad \bar{\bm J} \quad\overlinebold{J}$

$\scriptscriptstyle \overline{\bm M}\quad \bar{\bm M} \quad\overlinebold{M}$
\end{document}


-

I suggest to use some markup command, say \mymatrix and the \closure command (by E. Gregorio (egreg), see the comprehensive symbol table) to provide a rule over the symbol which isn't to small or too wide.

\documentclass{article}

\usepackage{bm}

\newcommand{\closure}[2][3]{%
{}\mkern#1mu\overline{\mkern-#1mu#2}}

\newcommand{\mymatrix}[2][3]{%
\closure[#1]{\bm{#2}}%
}

\begin{document}
$\mymatrix{B}$
\end{document}

-