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....
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.
Sign up to join this communityThe 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}
\Alph
by \alph
for lowercase letters. See updated answer.
Jan 24, 2017 at 10:01
\boldmath $ x+y$