Latex\path命令内部\newcommand定义不起作用?

Latex\path命令内部\newcommand定义不起作用?,latex,renewcommand,Latex,Renewcommand,我想在latex文档中的\newcommand定义中使用\path命令。然而,我的定义并不像我期望的那样有效。一个最简单的例子是 \documentclass[12pt]{article} \usepackage{path} \newcommand{\code}[1]{\path!{#1}!} \begin{document} Testing the path command with: \code{this.texts.should.not.be.typeseted.on.a.single.l

我想在latex文档中的
\newcommand
定义中使用
\path
命令。然而,我的定义并不像我期望的那样有效。一个最简单的例子是

\documentclass[12pt]{article}
\usepackage{path}
\newcommand{\code}[1]{\path!{#1}!}
\begin{document}
Testing the path command with: \code{this.texts.should.not.be.typeseted.on.a.single.line}.

Testing the path command with: \path!this.texts.should.not.be.typeseted.on.a.single.line!.
\end{document}

在定义新命令时,我犯了什么错误?

简单地看,
\path
做了
\catcode
欺骗,很像
\verb
做的,因此,像
\verb
一样,它在其他命令中无法正常工作。(Cf.)显然,您在应用程序中做了一些额外的事情,否则您可以只说
\newcommand\code{\path}
,甚至说
\let\code\path
,这是因为命令将让
\path
拾取参数,而不是自己拾取参数。

非常有趣的是
\path
选择使用
标记,而不是大括号。看起来这会引起问题。我无法用
de宏检查它是如何展开的。@progo:分隔符可以任意选择。您也可以使用
+
或string.yah中未包含的任何其他符号,但为什么不使用常规的
\command{args}
语法…非常感谢。我想你的链接解决了我的问题,我不能在另一个逗号的参数中使用
\path