8

I am presenting a paper (not mine) in which almost all math symbols are in \mathbf. I know I can put \boldmath in the preamble but it does not typesets it as the regular \mathbf does (upright).

So, is there a way to change the behavior of boldmath macro so that it typesets everything in \mathbf (except, possibly, greek letters for which the behavior of \boldmath is great).

And, if so, what command should I use when I want something in particular to be back to the usual non-bold italic font?

P.S. I also noticed the \boldmath command changes all other symbols such as operators and logicals. I would like them to stay in their non-bold usual way. Maybe at this point it would be easier to just change math font, I just don't know how to do it.

Thank you in advance

  • Which document class do you use? – Mico Jun 5 '16 at 18:40
10

Change the math code of the letters; some brute force is necessary.

\documentclass{article}

\DeclareSymbolFont{boldletters}{OT1}{cmr}{bx}{n}
\DeclareSymbolFontAlphabet{\mathbf}{boldletters} % not to waste a family
\DeclareMathSymbol{a}{\mathalpha}{boldletters}{`a}
\DeclareMathSymbol{b}{\mathalpha}{boldletters}{`b}
\DeclareMathSymbol{c}{\mathalpha}{boldletters}{`c}
\DeclareMathSymbol{d}{\mathalpha}{boldletters}{`d}
\DeclareMathSymbol{e}{\mathalpha}{boldletters}{`e}
\DeclareMathSymbol{f}{\mathalpha}{boldletters}{`f}
\DeclareMathSymbol{g}{\mathalpha}{boldletters}{`g}
\DeclareMathSymbol{h}{\mathalpha}{boldletters}{`h}
\DeclareMathSymbol{i}{\mathalpha}{boldletters}{`i}
\DeclareMathSymbol{j}{\mathalpha}{boldletters}{`j}
\DeclareMathSymbol{k}{\mathalpha}{boldletters}{`k}
\DeclareMathSymbol{l}{\mathalpha}{boldletters}{`l}
\DeclareMathSymbol{m}{\mathalpha}{boldletters}{`m}
\DeclareMathSymbol{n}{\mathalpha}{boldletters}{`n}
\DeclareMathSymbol{o}{\mathalpha}{boldletters}{`o}
\DeclareMathSymbol{p}{\mathalpha}{boldletters}{`p}
\DeclareMathSymbol{q}{\mathalpha}{boldletters}{`q}
\DeclareMathSymbol{r}{\mathalpha}{boldletters}{`r}
\DeclareMathSymbol{s}{\mathalpha}{boldletters}{`s}
\DeclareMathSymbol{t}{\mathalpha}{boldletters}{`t}
\DeclareMathSymbol{u}{\mathalpha}{boldletters}{`u}
\DeclareMathSymbol{v}{\mathalpha}{boldletters}{`v}
\DeclareMathSymbol{w}{\mathalpha}{boldletters}{`w}
\DeclareMathSymbol{x}{\mathalpha}{boldletters}{`x}
\DeclareMathSymbol{y}{\mathalpha}{boldletters}{`y}
\DeclareMathSymbol{z}{\mathalpha}{boldletters}{`z}
\DeclareMathSymbol{A}{\mathalpha}{boldletters}{`A}
\DeclareMathSymbol{B}{\mathalpha}{boldletters}{`B}
\DeclareMathSymbol{C}{\mathalpha}{boldletters}{`C}
\DeclareMathSymbol{D}{\mathalpha}{boldletters}{`D}
\DeclareMathSymbol{E}{\mathalpha}{boldletters}{`E}
\DeclareMathSymbol{F}{\mathalpha}{boldletters}{`F}
\DeclareMathSymbol{G}{\mathalpha}{boldletters}{`G}
\DeclareMathSymbol{H}{\mathalpha}{boldletters}{`H}
\DeclareMathSymbol{I}{\mathalpha}{boldletters}{`I}
\DeclareMathSymbol{J}{\mathalpha}{boldletters}{`J}
\DeclareMathSymbol{K}{\mathalpha}{boldletters}{`K}
\DeclareMathSymbol{L}{\mathalpha}{boldletters}{`L}
\DeclareMathSymbol{M}{\mathalpha}{boldletters}{`M}
\DeclareMathSymbol{N}{\mathalpha}{boldletters}{`N}
\DeclareMathSymbol{O}{\mathalpha}{boldletters}{`O}
\DeclareMathSymbol{P}{\mathalpha}{boldletters}{`P}
\DeclareMathSymbol{Q}{\mathalpha}{boldletters}{`Q}
\DeclareMathSymbol{R}{\mathalpha}{boldletters}{`R}
\DeclareMathSymbol{S}{\mathalpha}{boldletters}{`S}
\DeclareMathSymbol{T}{\mathalpha}{boldletters}{`T}
\DeclareMathSymbol{U}{\mathalpha}{boldletters}{`U}
\DeclareMathSymbol{V}{\mathalpha}{boldletters}{`V}
\DeclareMathSymbol{W}{\mathalpha}{boldletters}{`W}
\DeclareMathSymbol{X}{\mathalpha}{boldletters}{`X}
\DeclareMathSymbol{Y}{\mathalpha}{boldletters}{`Y}
\DeclareMathSymbol{Z}{\mathalpha}{boldletters}{`Z}

\begin{document}

$a+b=\mathnormal{c}$

\end{document}

For the occasional letter in the default style, use \mathnormal as shown.

enter image description here

With some less brute force:

\documentclass{article}

\DeclareSymbolFont{boldletters}{OT1}{cmr}{bx}{n}
\DeclareSymbolFontAlphabet{\mathbf}{boldletters} % not to waste a family

\makeatletter
\begingroup
\def\DMS@#1{\DeclareMathSymbol{#1}{\mathalpha}{boldletters}{`#1}}
\count@=`a \advance\count@\m@ne
\@whilenum\count@<`z\do{
  \advance\count@\@ne
  \lccode`A=\count@
  \lowercase{\DMS@{A}}
}
\count@=`A \advance\count@\m@ne
\@whilenum\count@<`Z\do{
  \advance\count@\@ne
  \uccode`a=\count@
  \uppercase{\DMS@{a}}
}
\endgroup
\makeatother

\begin{document}

$a+b=\mathnormal{c}$

$abcdefgz$

$ABCDEFGZ$

\end{document}

enter image description here

  • 1
    Why \loop...\repeat and not \@whilenum? – Henri Menke Jun 5 '16 at 18:14
  • 1
    @HenriMenke Laziness. Happier, now? ;-) – egreg Jun 5 '16 at 18:15
4

If you're using one of "basic" LaTeX document classes -- article, report, and book -- or a document class that is built on one of these classes, you could proceed as follows:

enter image description here

\documentclass{article}
\everymath{\bf}
\everydisplay{\bf}
\begin{document}
$a^2+b^2=c^2$

$\cos^2{\theta}+\sin^2(\theta)=1 $
\end{document}

Observe that a, b, c, 1 and 2 are rendered in bold, whereas +, =, cos, sin and \theta are not. I understand that's the look you want. Please advise if I misinterpreted your requirements.

Aside: Do note that \bf -- as well as \it, \rm, \tt, \sf, \sl, and \sc -- is nowadays (rightly!) considered deprecated in a LaTeX document and that its use is even frowned upon. For sure, some LaTeX document classes (such as memoir) no longer even provide a definition for \bf. However, as is explained in more detail in this answer to the query Is there any reason not to use \let to redefine a deprecated control sequence to the currently recommended one?, you're actually alright using \bf if you use one of the "standard" document classes. More precisely, \bf will then behave exactly as it would in a PlainTeX document. In particular, \bf in an inline or display math setting is automatically re-interpreted as \mathbf.

You will get rid of the automatic-bold look as soon as the need for it has expired, right? :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.