【问题标题】:Redefining Commands with Parameters using \newenvironment使用 \newenvironment 重新定义带参数的命令
【发布时间】:2009-01-30 03:55:39
【问题描述】:

根据这个问题:

Redefining Commands in a New Environment

如何重新定义(或使用\def 定义)使用参数的宏?我不断收到illegal parameter definition in \foo 错误。因为我需要自定义分隔符,所以我不能使用\newcommand\renewcommand

我的代码的一般形式如下所示:

\newenvironment{foo}{% 
    ...spacing stuff and counter defs...
    \def\fooitem#1. #2\endfooitem{%
        ...stuff...
    }
    \def\endfooitem{endfoo}
}
{...after material (spacing)...}

这一定是可能的。现在我使用的是纯 TeX 定义(正如我在上面的问题中提到的),但我真的很想与 LaTeX 系统保持一致。

【问题讨论】:

    标签: latex tex


    【解决方案1】:

    您需要将每个嵌套定义的 # 字符加倍。在内部,\newcommand 或 \newenvironment 正在调用 \def。

    \newenvironment{foo}{% 
      ...
      \def\fooitem##1. ##2\endfooitem{%
        ...
    

    除此之外,这是做你想做的事的方法;没有纯 LaTeX 方法来定义带有分隔参数的宏。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-12-30
      • 2020-12-24
      • 2016-02-01
      • 2013-10-07
      • 1970-01-01
      • 2017-10-07
      • 1970-01-01
      • 2011-06-14
      相关资源
      最近更新 更多