7

Consider the following MWE:

\documentclass{amsart}

\begin{document}
Let $(M,d)$ be a metric space. For any $x \in M$ and $r > 0$, the \textbf{open ball of radius $r$ around $x$} is the set 

\begin{equation}
    B_r(x) := \{y \in M : d(y,x) < r\}.
\end{equation}
\end{document}

Is there any possibility that the math symbols are also bold by default, i.e. without writing explicitly something like \mathbf{a + b}?

5
  • 2
    \boldmath somewhere before \textbf, but it does not look nice having both text and math in bold font, in my point of view. \boldmath enables bold math (if the symbol is available in bold font at all) for the rest of the document or until \unboldmath undoes it
    – user31729
    Jan 4, 2017 at 21:23
  • @ChristianHupfer Oh really nice! Just made the command \newcommand{\bld}[1]{\boldmath\textbf{#1}\unboldmath} for highlighting something and it worked as expected. Thank you. Jan 4, 2017 at 21:28
  • 4
    not relevant to question, but ... please do not leave a blank line before \begin{equation}. it messes up the vertical spacing, Jan 4, 2017 at 21:34
  • @barbarabeeton Thank you so much! This was bothering me all the time when I wrote my report. Jan 4, 2017 at 21:41
  • 1
    @barbarabeeton Oh dear, that was very enlightening, I've been doing it wrong all the time, thank you!
    – ZirconCode
    Jan 4, 2017 at 21:41

2 Answers 2

8

Update 2023

With a newer release of LaTeX, there's a much better way to accomplish the task.

\documentclass{amsart}

\AddToHook{cmd/bfseries/after}{\boldmath}
\AddToHook{cmd/normalfont/after}{\unboldmath}

\begin{document}

\section{Bad typesetting}

Let $(M,d)$ be a metric space. For any $x \in M$ and $r > 0$, the 
\textbf{open ball of radius $r$ around $x$} is the set 
\begin{equation}
    B_r(x) := \{y \in M : d(y,x) < r\}.
\end{equation}

Let's see: \textbf{M \normalfont \(M\) M}

\section{Good typesetting}

Let $(M,d)$ be a metric space. For any $x \in M$ and $r > 0$, the 
\emph{open ball of radius~$r$ around~$x$} is the set 
\begin{equation}
    B_r(x) := \{y \in M : d(y,x) < r\}.
\end{equation}

\end{document}

enter image description here

Older answer, don't use unless you have an old TeX distribution.

You might update the definition of \bfseries to also issue \boldmath. However I recommend using \emph for emphasis.

Never leave a blank line before an equation or other math display environment. Use ties, as I show in the second example.

\documentclass{amsart}

\makeatletter
\DeclareRobustCommand\bfseries{%
  \not@math@alphabet\bfseries\mathbf
  \fontseries\bfdefault\selectfont
  \boldmath % <-- added
}
\makeatother

\begin{document}

\section{Bad typesetting}

Let $(M,d)$ be a metric space. For any $x \in M$ and $r > 0$, the 
\textbf{open ball of radius $r$ around $x$} is the set 
\begin{equation}
    B_r(x) := \{y \in M : d(y,x) < r\}.
\end{equation}

\section{Good typesetting}

Let $(M,d)$ be a metric space. For any $x \in M$ and $r > 0$, the 
\emph{open ball of radius~$r$ around~$x$} is the set 
\begin{equation}
    B_r(x) := \{y \in M : d(y,x) < r\}.
\end{equation}

\end{document}

enter image description here

Why is it bad using boldface type? Because it's too heavy. Why is it worse to embolden math? Because math symbols have a meaning that also depends on their typographic nature: to a mathematician, a boldface italic ‘r’ is not the same as a medium italic ‘r’.

4
  • @Kobi You should have first commented that the answer does no longer work: it did at the time it was written. Anyway, I provided a new answer that works with the current LaTeX. Here the custom is quite different than in SO.
    – egreg
    Jul 4, 2023 at 17:01
  • If it is worse to embolden math is subjective or context-sensitive. If someone may have two different symbols being the same letter in different styles, it is. If not, it isn't. I avoid having such symbols because distinguishing them while reading is difficult and to have the option to typeset maths in different styles. Like I do not read the boldness in normal text, I do not read the boldness in math text.
    – matj1
    Oct 11, 2023 at 14:23
  • That solution (Update 2023) breaks (behaves unintuitively) when the font is switched inside a \textbf. The result of \textbf{\normalfont \(M\) M} is that the textual M is normal and the mathematical M is bold. I think that this result is undesirable. This problem is encountered in (among others) description lists when I use enumitem and have \setlist[description]{font=\normalfont} to have the labels in the normal font. The labels are bold by default, so it makes maths bold, and \normalfont doesn't unenbolden it. It could be fixed by redefining \normalfont to include \unboldmath.
    – matj1
    Oct 25, 2023 at 15:05
  • 1
    @matj1 Fixed as requested
    – egreg
    Oct 25, 2023 at 15:11
6

Update \textbf to also execute \boldmath:

enter image description here

\documentclass{amsart}

\usepackage{mathtools}

\let\oldtextbf\textbf
\renewcommand{\textbf}[1]{\oldtextbf{\boldmath #1}}

\begin{document}
Let $(M,d)$ be a metric space. For any $x \in M$ and $r > 0$, the \textbf{open ball of radius~$r$ around~$x$} is the set 
\begin{equation}
  B_r(x) \vcentcolon= \{y \in M \mid d(y,x) < r\}.
\end{equation}

\end{document}

For some this may change the notation, since there could be a different interpretation of r and r, for example.


A wiser choice for the redefinition of \textbf:

\usepackage{letltxmacro}
\LetLtxMacro\oldtextbf\textbf% http://tex.stackexchange.com/q/88001/5764
\DeclareRobustCommand{\textbf}[1]{\oldtextbf{\boldmath #1}}
4
  • Be careful when doing this to robustified commands.
    – egreg
    Jan 4, 2017 at 21:33
  • 1
    @egreg: It may be better to declare it robust so as to avoid issues with a possible expansion of \boldmath. Or \renewcommand{\textbf}[1]{\oldtextbf{\protect\boldmath #1}}?
    – Werner
    Jan 4, 2017 at 21:35
  • 1
    Look at the documentation of letltxmacro to know why, or When to use \LetLtxMacro. Doing \DeclareRobustMacro{\textbf}[1]{\oldtextbf{\boldmath#1}} leads to an infinite loop.
    – egreg
    Jan 4, 2017 at 21:43
  • Thanks for correcting the :=. I think that it might be preferable still to use \coloneqq (also from mathtools), defined as \mathrel{\vcentcolon\mkern-1.2mu=}.
    – wchargin
    Jan 5, 2017 at 2:06

You must log in to answer this question.

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