3

The \boldmath command will make all symbols used in math mode bold.

I'm curious if there is an analogous command that allows the user to specify which characters to make bold in math mode. This functionality would be useful in a document where the bold version of a symbol is used more often than the non-bold version of that symbol and also where the bold version of other symbols are not regularly used.

Here's a mwe:

\documentclass{article}

\usepackage[a6paper, margin=0.25in]{geometry}
\usepackage{bm}
\setlength{\parindent}{0pt}
\pagestyle{empty}

\begin{document}

Nothing is bold here.
\[
  Av=\lambda\cdot v
\]
Everything is bold here.
\boldmath% Issuing `\boldmath` makes every symbol in math mode bold.
\[
  Av=\lambda\cdot v
\]
\unboldmath% Issuing `\unboldmath` untoggles `\boldmath`.
I really just want the $A$ and $v$ bold.
\[
  \bm{A}\bm{v}=\lambda\cdot \bm{v}
\]



\end{document}

enter image description here

Of course, it's not terribly cumbersome to type \bm{A} or even to alias \bm{A} as something like \bA. However, if my document has thousands of equations in it and A is almost always supposed to be bold, then the functionality I'm looking for would be genuinely useful.

2 Answers 2

3

You can adjust the mathcode of A and V to use bold italic

enter image description here

\documentclass{article}

\usepackage[a6paper, margin=0.25in]{geometry}

\setlength{\parindent}{0pt}
\pagestyle{empty}
\DeclareSymbolFont{boldletters}     {OML}{cmm} {b}{it}
\DeclareMathSymbol{\unboldA}{\mathalpha}{letters}{`A}
\DeclareMathSymbol{A}{\mathalpha}{boldletters}{`A}
\DeclareMathSymbol{\unboldv}{\mathalpha}{letters}{`v}
\DeclareMathSymbol{v}{\mathalpha}{boldletters}{`v}
\begin{document}

A and v bold
\[
  Av=\lambda\cdot v
\]
A and v not bold
\[
  \unboldA \unboldv=\lambda\cdot \unboldv
\]




\end{document}
2

I'd prefer to use semantic markup, rather than defaults: say

\newcommand{\mm}[1]{\bm{#1}}% matrix
\newcommand{\vv}[1]{\bm{#1}}% vector

and in the body of the document you type

$\mm{A}\vv{v}=\lambda\vv{v}$

Maybe more tedious to type, but clearer.

Anyway, you can accomplish your desiderata by using math active characters. In the example I use newtx so as to show that you don't need to chase the math fonts definitions.

\documentclass{article}
\usepackage{amsmath}
\usepackage{newtx}% for testing
\usepackage{bm}% after math font packages

\ExplSyntaxOn
\AtBeginDocument
 {
  \clist_map_inline:nn
   {% the list of characters you want to embolden by default
    A,B,u,v,w
   }
   {
    % keep the original meaning in \uA,\uB and so on
    \exp_args:Nc \mathchardef { u#1 } = \mathcode`#1 \scan_stop:
    % define \emboldened<char> to be \bm{\u<char>}
    \cs_new_protected:cpe { emboldened#1 } { \exp_not:N \bm { \exp_not:c { u#1 } } }
    % set the active <char> to be equivalent to \emboldened<char>
    \char_set_active_eq:Nc #1 { emboldened#1 }
    % set the character to be math active
    \mathcode`#1 = "8000 \scan_stop:
   }
 }
\ExplSyntaxOff

\begin{document}

$Av = \lambda v$

$u+v=v+u$

$\uA+\uB=3$

\end{document}

enter image description here

David's answer is possibly more efficient, if you know where to look for math symbol font definitions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .