# Unbold a \boldsymbol in mathmode?

I want to create a command that get an unbold character from a boldsymbol in mathmode.

In my setup every vector is in bold font for example $\boldsymbol{x}$ and the command \coef{\boldsymbol{x}}{i} I want to create is for writing the i-th coefficient of this vector and should result in $x_i$ with normal font. I would like to be able to use it for any vector (which are all boldsymbols).

I tried the $\mathnormal$ command as shown in the code but it does not do anything.

So is it possible to unbold a boldsymbol in math mode?

\documentclass[12pt,a4paper]{letter}
\usepackage[latin1]{inputenc}
\usepackage{amsmath,amsfonts,amssymb}

\newcommand{\x}{\boldsymbol{x}}
\newcommand{\coef}[2]{\mathnormal{#1}_{#2}}

\begin{document}
The vector $\x$ and its coefficients $\coef{\x}{i}$.
\end{document}

• You should load bm, which features a much better implementation of \boldsymbol. – egreg Aug 25 '15 at 8:20
• I actually already tried to use this package but, I faced the same problems. – Tonio Bonnef Aug 25 '15 at 8:26

\boldsymbol is still inside \mathnormal, thus the setting of \mathnormal is overwritten by \boldsymbol. A way to solve this is to redefine \boldsymbol inside \coef:

\documentclass[12pt,a4paper]{letter}
\usepackage[latin1]{inputenc}
\usepackage{amsmath,amsfonts,amssymb}

\newcommand{\x}{\boldsymbol{x}}
\newcommand{\coef}[2]{%
\begingroup
\renewcommand*{\boldsymbol}[1]{##1}%
#1_{#2}%
\endgroup
}

\begin{document}
The vector $\x$ and its coeficients $\coef{\x}{i}$.
\end{document}


• Thanks that working fine, although I don't really get what exactly means \renewcommand*{\boldsymbol}[1]{##1}%, in particular why the * and what means the 2 # in ##1. – Tonio Bonnef Aug 25 '15 at 8:24
• @TonioBonnef The star form does not allows paragraphs (\par) as argument. And # needs to be doubled inside the definition of another command. – Heiko Oberdiek Aug 25 '15 at 8:41

A variant of Heiko's method; I also use bm, that features a better implementation of \boldsymbol (that can also be called \bm). With \ifcoef you can disable \boldsymbol more easily also in other situations, by simply setting \coeftrue (in a group).

\documentclass[12pt,a4paper]{article}

\usepackage{amsmath,amssymb,bm}

\newif\ifcoef
\newcommand{\bvec}[1]{%
\ifcoef #1\else\bm{#1}\fi
}
\newcommand{\coef}[2]{%
\begingroup
\coeftrue
{#1}_{#2}%
\endgroup
}

\newcommand{\x}{\bvec{x}}

\begin{document}
The vector $\x$ and its coefficients $\coef{\x}{i}$.

The vector $\bvec{\Gamma}$ and its coefficients
$\coef{\bvec{\Gamma}}{i}$

\end{document}