I would like to define a newcommand that takes one required parameter, but instead of passing it in using {...} as normal, to use a different parameter delineator like the \verb command does (e.g., \mycmd|args|). Trying to do this with a normal \newcommand definition seems to behave strangely.


2 Answers 2


If you do not want catcode sanitization:

    {\def\domyverb##1#1{ the argument was `##1'}%

and then use it as follows.




It mostly depends on what you want to do. If all you need is to use the argument "as is", then


will do. This doesn't check whether \mycmd is defined; if you need the check, then use


If you need this to do "verbatim" things, the definition must be quite more complicated.

  • what about defining a command whose argument can be placed between a pair of arbitrary symbols? How is \verb defined so that \verb|spleen|, \verb+spleen+, etc. work? Commented Jun 29, 2011 at 23:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .