As the title says, is there any way to make bold text automatically also be typeset in sans serif? I'm thinking something along the lines of
\renewcommand{\bfdefault}{???}
I don't know what to redefine to though?
As the title says, is there any way to make bold text automatically also be typeset in sans serif? I'm thinking something along the lines of
\renewcommand{\bfdefault}{???}
I don't know what to redefine to though?
The definition of \bfseries in latex.ltx reads
\DeclareRobustCommand\bfseries
{\not@math@alphabet\bfseries\mathbf
\fontseries\bfdefault\selectfont}
so it's sufficient to say
\makeatletter
\DeclareRobustCommand\bfseries{%
\not@math@alphabet\bfseries\mathbfsf
\fontfamily\sfdefault\fontseries\bfdefault\selectfont
}
\DeclareMathAlphabet{\mathbfsf}{OT1}{\sfdefault}{\bfdefault}{n}
\makeatother
Here's the complete example:
\documentclass{article}
\usepackage{lmodern} % for sans serif bold slanted
\makeatletter
\DeclareRobustCommand\bfseries{%
\not@math@alphabet\bfseries\mathbfsf
\fontfamily\sfdefault\fontseries\bfdefault\selectfont
}
\DeclareMathAlphabet{\mathbfsf}{OT1}{\sfdefault}{\bfdefault}{n}
\makeatother
\begin{document}
This {\bfseries is sans} and this \textbf{too}; what
about math? Here it is: $a\textbf{x}$; also italic is
applied: \textbf{\textit{abc}} or \textit{\textbf{abc}}.
\end{document}
Of course if serif math bold is wanted, \mathbfsf should remain \mathbf and the font alphabet declaration should be removed.

Have you tried inserting
\renewcommand{\textbf}[1]{{\bfseries\sffamily#1}}
in the preamble of your document? Note the double pair of curly braces; the innner pair serves to constrain the application of \bfseries\sffamily to the argument of \textbf.
Addendum: As the comments by cgnieder and egreg allude to, the LaTeX kernel (see the file latex.ltx, ca. line 3720) provides the following definition of \textbf:
\DeclareTextFontCommand{\textbf}{\bfseries}
The macro \DeclareTextFontCommand takes care to keep things tidy if, say, \textbf is encountered while TeX is in math mode. To keep things equally tidy, then, it's preferable to redefine \textbf as follows:
\DeclareTextFontCommand{\textbf}{\bfseries\sffamily}
DeclareTextFontCommand route.
– Mico
Oct 31 '14 at 12:26
\bfseries, not \textbf.
– egreg
Oct 31 '14 at 12:31
\textbf. He/she may want to be able to continue to use \bfseries on its own, e.g., for typesetting something in bold without switching to sans-serif. Similarly, he/she may not want to modify the meaning of \mathbf just because \textbf gets modified.
– Mico
Oct 31 '14 at 12:44