1

I have been using

\def\H{\bm{H}}

to define bold letters in math mode. Is there a way I can define a general rule for any letters? Like I want a rule that allow

\*anyletters*{\bm{*anyletter}*
% For example \I -> \bm{I} etc....
  • 1
    just letters or do you want the whole expression bold, in which case \boldmath $ x+y$ – David Carlisle Feb 6 '16 at 23:16
1

The following code defines \bmA to be \bm{A} for A running over all letters in the alphabet. Please do not use single letter macros, as these tend to have special meaning (accents, special symbols).

\documentclass{article}
\usepackage{bm}
\makeatletter
\newcounter{letter}
\setcounter{letter}{1}
\@whilenum\value{letter}<27\do{% loop over all letters in the alphabet
  % \def\bmA{\bm{A}}, where A runs over all letters
  %   Remove letters `bm'  vv  if you don't care about breaking LaTeX
  \expandafter\edef\csname bm\Alph{letter}\endcsname{\noexpand\bm{\Alph{letter}}}
  \expandafter\edef\csname bm\alph{letter}\endcsname{\noexpand\bm{\alph{letter}}}
  \stepcounter{letter}%
}
\makeatother
\begin{document}
Hungarian umlaut \H{o}

Polish suppressed-L \L

Scandinavian O-with-slash \O

pilcrow \P

section symbol \S

$\bmA \bmZ \bma \bmz$
\end{document}

enter image description here

  • returning after about a year - how do you make the same rule for lower case as well? – Quang Thinh Ha Jan 23 '17 at 23:13
  • 2
    @QuangThinhHa Just add another line in the loop, substituting \Alph by \alph for lowercase letters. See updated answer. – Henri Menke Jan 24 '17 at 10:01

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.