
我一直在使用
\def\H{\bm{H}}
在數學模式下定義粗體字母。有沒有一種方法可以定義一般規則任何字母?就像我想要一個允許的規則
\*anyletters*{\bm{*anyletter}*
% For example \I -> \bm{I} etc....
答案1
以下程式碼定義\bmA
用於\bm{A}
遍歷A
字母表中的所有字母。請不要使用單字母宏,因為它們往往具有特殊意義(重音符號、特殊符號)。
\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}