This question is motivated by a question asked me by a friend who is working on his thesis in mathematics. His section headings occasionally contain math, which:
- he would like to be in boldface to match the rest of the section title; but
- he would like to be medium-weight when it occurs in the table of contents, as with the rest of the section title.
He was using \mathbf
to make the math boldface in his section headings; this of course also made them bold in the table of contents. I gave him a simple solution which inserted code at the beginning of the table of contents, which would make \mathbf
pass its arguments unchanged. Of course, \mathbf
also makes its arguments upright rather than math-italics, which I would also consider less than desirable; and it has no effect on e.g. greek characters, for which you would have to use something like the \bm
command of bm.sty
instead. (You could play the same trick with \bm
as with \mathbf
in the table of contents, but having to repeatedly use different math macros for all math in section headings to me seems inelegant.)
What would be the most elegant way to automatically render all math (including non-latin characters) in bold-face for section headings, but the normal medium-weight everywhere else (including the entries of the table of contents)?
$a$
is not the same as$\bm{a}$
(the packagebm
provides the command). If there are math formulas in titles, it would probably be best to avoid having them in boldface to begin with.