2

I would like to use the \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?

ladi
  • 1,518
  • 2
  • 13
  • 19
  • Very interesting that the `\path` chooses to use `!` marks instead of curly braces. Looks like it causes problems. I couldn't check with `de-macro` how it expands. – mike3996 Nov 11 '10 at 10:03
  • @progo: The delimiter may be chosen arbitrarly. You could also use `+` or any other symbol not conained in the string. – ladi Nov 11 '10 at 15:25
  • yah, but why not use the regular `\command{args}` syntax... – mike3996 Nov 11 '10 at 16:32

1 Answers1

2

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.

0xC0000022L
  • 20,597
  • 9
  • 86
  • 152
Ulrich Schwarz
  • 7,598
  • 1
  • 36
  • 48
  • Thanks a lot. I figure that your link solves my question that I can not use `\path` inside the arguments of another comman. – ladi Nov 14 '10 at 09:18