Latex \path command inside \newcommand definition not working?
I would like to use t开发者_Python百科he \path
command inside a \newcommand
definition inside a latex document. However my definition does not work as I would expect it to work. A minimal example for this is
\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}
What is the error I am making when defining the new command?
From a brief look, \path
does \catcode
trickery, much like \verb
does, and so, like \verb
, it will not work correctly within other commands. (Cf. Why doesn’t verbatim work within …?) Obviously, you are doing something extra in your application, otherwise you could just say \newcommand\code{\path}
or even \let\code\path
, which works because the command will then let \path
pick up the parameter and not do it itself.
精彩评论