0

There are a lot of questions asking how to get math symbols to appear in bold, which I know that you can do with \mathbf and amsmath's \boldsymbol.

But is there a way to automatically bold my inline mathematical equations when (and only when) the surrounding text-mode contents are bold?

For instance, I would like the following:

The quick brown fox \textbf{jumps over \( \sin (256) \) lazy dogs.} \\
The quick brown fox \textbf{jumps over $\sin (256)$ lazy dogs.} \\
The quick brown fox jumps over \( \sin (256) \) lazy dogs. \\
The quick brown fox jumps over $\sin (256)$ lazy dogs. \\
The quick brown fox {\bfseries jumps over \( \sin (256) \) lazy dogs.} \\
The quick brown fox {\bfseries jumps over $\sin (256)$ lazy dogs.} \\
The quick brown fox \textbf{jumps over \( 3^{2\cos 10} \) lazy dogs.} \\
The quick brown fox \textbf{jumps over $3^{2\cos 10}$ lazy dogs.} \\
The quick brown fox {\bfseries jumps over \( 3^{2\cos 10} \) lazy dogs.} \\
The quick brown fox {\bfseries jumps over $3^{2\cos 10}$ lazy dogs.}

to render as:

The quick brown fox jumps over sin(256) lazy dogs.
The quick brown fox jumps over sin(256) lazy dogs.
The quick brown fox jumps over sin(256) lazy dogs.
The quick brown fox jumps over sin(256) lazy dogs.
The quick brown fox jumps over sin(256) lazy dogs.
The quick brown fox jumps over sin(256) lazy dogs.
The quick brown fox jumps over 32 cos(10) lazy dogs.
The quick brown fox jumps over 32 cos(10) lazy dogs.
The quick brown fox jumps over 32 cos(10) lazy dogs.
The quick brown fox jumps over 32 cos(10) lazy dogs.

1
  • 1
    There is a reason that this isn't done automatically. In math above a certain level, it's not unusual to define the "same" letter in different styles (italic, boldface, script, ...) to mean different things. Automatically setting all math letters as bold in, say, a bold section heading could change the meaning and cause serious confusion and lead to misunderstanding or lack of comprehension by the reader. Commented Dec 4, 2022 at 3:30

1 Answer 1

3

use

\newcommand\allbold[1]{\textbf{\boldmath#1}}

enter image description here

\documentclass{article}
\newcommand\allbold[1]{\textbf{\boldmath#1}}
\begin{document}

The quick brown fox {jumps over \( \sin (256) \) lazy dogs.} 

The quick brown fox \allbold{jumps over \( \sin (256) \) lazy dogs.} 

\end{document}
3
  • Can I somehow redefine \textbf itself to have this functionality? One of my goals is for mathematical terms in my glossaries-extra glossary to appear in bold. Commented Dec 4, 2022 at 1:08
  • 1
    you could, but I wouldn't: simply use \bfseries\boldmath when specifying your glossaries setup Commented Dec 4, 2022 at 1:32
  • Great idea—thank you! Commented Dec 4, 2022 at 3:41

You must log in to answer this question.

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