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
  • 1
    just letters or do you want the whole expression bold, in which case \boldmath $ x+y$ Feb 6, 2016 at 23:16

1 Answer 1

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

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

You must log in to answer this question.

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