I'd like to create a command (\newcommand
) that does some decoration around a text (basically drawing a box around the text), for technical reports:
Eg like:
Use \pdobj{frob}{noz zle} for achievers
renders like:
Now the argument text (in this case frob
and noz zle
) very commonly uses the tilde-symbol ~
.
Since tilde is obviously special, I currently have to use
And \pdobj{slurp$\sim$}{} they did.
to achieve:
Now, what I would really like to do is to simply write
And \pdobj{slurp~}{} they did.
for the same effect.
As far as I understand this would require to re-define the ~
command, with something like
\def~{$\sim$}
While this seems to work, it also makes the traditional use of ~
as a non-breaking space (outside of my command) impossible.
However, the \url
command somehow does the trick to render ~
as some special glyphs (e.g. \url{~T}
) without affecting the NBSP-use outside its scope.
I had a looked at url.sty
, but frankly, this is way beyond my TeX-foo.
So, is there are (simple/easy/straightforward) way to make ~
do something completely different when encountered inside an argument to my command vs outside?
~
when it has catcode other. But I guess you actually know that :)