快速制作 26 个宏(每个字母一个)
不要为每个字母创建一个宏,如
\def\bA{\mathbf{A}}
...
\def\bZ{\mathbf{Z}}
是否有一种方法可以循环字符类(如大写字母)并为每个字母生成宏?我还想对希腊字母执行相同的操作(使用 bm
而不是 mathbf
)。
Instead of making a macro for each letter, as in
\def\bA{\mathbf{A}}
...
\def\bZ{\mathbf{Z}}
Is there a way to loop over a character class (like capital letters) and generate macros for each? I'd also like to do the same for Greek letters (using bm
instead of mathbf
).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
希腊语新功能
New for Greek
扩展安德鲁的答案,这是一个没有
\expandafter
的解决方案:这将定义
\bA
、\bB
等,以扩展为\mathbb{A}
、\mathbb{B}
等等。Expanding on Andrew's answer, here is a solution without
\expandafter
:This will define
\bA
,\bB
, and so on, to expand to\mathbb{A}
,\mathbb{B}
, and so on.定义一个命令不是更好
,它可以在文本模式和数学模式下使用。
用法:
结果:
F(x)='inegral delta(x)'dx
其中 F 是 blah blah blah,'delta' 是 halb halb halb...
外部美元用于离开数学(罗马)模式,因为
\boldmath 命令在数学模式下无效。内心的切换回数学(粗体)。附加大括号 (
${\boldmath
) 确保\boldmath
命令仅适用于#1
此代码的另一个优点是测试新命令
\bb
和\bg
的存在。所以你不能轻易地使 LaTeX makros 崩溃。我希望这就是您正在寻找的。
Wouldn't be better to define one command
and it can be used both in
text
mode andmath
mode.Usage:
Result:
F(x)='inegral delta(x)'dx
Where F is blah blah blah and 'delta' is halb halb halb...
Outer dollars are there to leave math (roman) mode because
\boldmath
command has no effect in math mode. Inner ones switch back to math (bold). Additional braces (${\boldmath
) ensures that\boldmath
command will work only with#1
Another advantage of this code is testing new commands for existence of
\bb
and\bg
. So you can't crash LaTeX makros easily.I hope this is what you're looking for.
我建议这样做:
正如克劳利所说,对于所有其他字母表也是如此。然而,如果你真的想使用 LaTeX 代码来做到这一点,这里有一个似乎可行的方法:
我记不清其中有多少个 'expandafter'!要获得小写字母,请将 Alpha 替换为 alpha。
I would recommend doing:
as Crowley says, and similar for all the other alphabets. However, if you really want to do it using LaTeX code, here's one that seems to work:
I lost count of how many 'expandafter's there are in that! To get lowercase letters, replace the Alph by alph.