代码之家  ›  专栏  ›  技术社区  ›  ladi

Latex\path命令在\newcommand定义中不起作用?

  •  1
  • ladi  · 技术社区  · 15 年前

    我想用 \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}
    

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

    1 回复  |  直到 15 年前
        1
  •  2
  •   0xC0000022L    6 年前

    从一个简短的眼神来看, \path \catcode 诡计,很像 \verb 是的,所以,就像 \动词 ,它将无法在其他命令中正常工作。(参见。 Why doesn’t verbatim work within …? )显然,您在应用程序中做了一些额外的事情,否则您可以说 \newcommand\code{\path} 甚至 \let\code\path ,因为命令将 \路径 拿起参数,不要自己动手。

    推荐文章