我想用 \path 命令内部 \newcommand 乳胶文档中的定义。然而,我的定义并不像我期望的那样有效。最简单的例子是
\path
\newcommand
\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 是的,所以,就像 \动词 ,它将无法在其他命令中正常工作。(参见。 Why doesnât verbatim work within â¦? )显然,您在应用程序中做了一些额外的事情,否则您可以说 \newcommand\code{\path} 甚至 \let\code\path ,因为命令将 \路径 拿起参数,不要自己动手。
\catcode
\verb
\动词
\newcommand\code{\path}
\let\code\path
\路径