例如
\def\if@nch@mpty#1{\def\temp@a{#1}\ifx\temp@a\@empty}
\def\f@nch@def#1#2{\if@nch@mpty{#2}\f@nch@gbl\def#1{\leavevmode}\else
\f@nch@gbl\def#1{#2\strut}\fi}
Run Code Online (Sandbox Code Playgroud)
Latex中@符号是什么意思
默认情况下,在 TeX 文档中,命令(也称为宏)只能使用字母命名[a-zA-Z],而不能使用诸如 之类的符号命名@。
这是为什么?因为每个字符都有一个类别代码(或简称为catcode[a-zA-Z] ),并且默认情况下只有 catcode 11 允许在宏中使用它。但是,令人惊奇的是,TeX 允许您更改角色的目录代码!cls因此,在/文件的开头sty,LaTeX 将 catcode 设置为@catcode 11。之后,它将其重置回默认值。
LaTeX 还包含两个命令\makeatletter和\makeatother来轻松更改@.
例如:
\makeatletter
% This is ok define new command with at character.
\def\command@with@at@character{%
Command With At Character.%
}
% And you can use it in the pair makeatletter/makeatother
\command@with@at@character
\makeatother
% But you CANNOT use the macro here!!! TeX will try to call \command
% but not \command@with@at@character, because `@` now does not have
% right catcode.
% \command@with@at@character
Run Code Online (Sandbox Code Playgroud)
请参阅\makeatletter 和 \makeatother 做什么? 以获得更多信息。
关于宏\catcode(可以帮助您更改角色的catcode),您可以从这里获得更多信息。
| 归档时间: |
|
| 查看次数: |
2414 次 |
| 最近记录: |