renewcommand

2020-09-12 15:28发布

## 编译环境 操作系统 * [x ] Windows 7/8/10 * [ ] macOS * [ ] Linux `若需勾选,请把[ ]改成[x]` Tex发行版 * [x ] TexLive ...

## 编译环境 操作系统 * [x ] Windows 7/8/10 * [ ] macOS * [ ] Linux `若需勾选,请把[ ]改成[x]` Tex发行版 * [x ] TexLive `2019` * [ ] MikTeX `版本号` * [ ] CTeX `若需勾选,请把[ ]改成[x]` ## 我的问题 假如已经有了命令A,该命令有一个必选参数 我该如何重定义该命令呢? ps:本来是想这么写\renewcommand{\A}[1]{\A{#1}},但是会报错,就不知道怎么办了
2条回答
nygNsEsvQdp7 - frank.xin
2020-09-13 09:58 .采纳回答
也可以用其他名字替换旧命令,再重新定义,例如: ``` \let\oldA\A \renewcommand{\A}[1]{\textbf{\oldA{#1}}} ``` 参考 [Can I redefine a command to contain itself?](https://tex.stackexchange.com/questions/47351/can-i-redefine-a-command-to-contain-itself "Can I redefine a command to contain itself?"),使用 `letltxmacro` 宏包可以规避一些潜在的问题: ``` \usepackage{letltxmacro} \LetLtxMacro{\oldemph}{\emph} \renewcommand{\emph}[1]{\textbf{\oldemph{#1}}} ```

一周热门 更多>