2009-01-30 103 views
1

根据这个问题参数:重新定义命令使用 newenvironment

Redefining Commands in a New Environment

一个人如何重新定义(或使用\def定义)使用参数宏?我不断收到illegal parameter definition in \foo错误。由于我需要自定义分隔符,因此我无法使用\newcommand\renewcommand

A的我的代码一般形式如下:

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

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

回答

1

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

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

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