I'm trying to write a simple example command that prints nothing without an argument, but with an argument it surrounds it with something.
I've read that the default value should be \@empty
and the simple \ifx\@empty#1
condition should do the job:
\newcommand{\optarg}[1][\@empty]{%
\ifx\@empty#1 {} \else {(((#1)))} \fi
}
\optarg % (((empty)))
\optarg{} % (((empty)))
\optarg{test} % (((empty))) test
The latter three commands all print the empty
word for some reason, and I want the first two to print nothing and the last to print (((test)))
.
I'm using TeXLive/Ubuntu. An ideas?