[texhax] Defining a command which runs differently based ion input argument

Lars Madsen daleif at imf.au.dk
Tue Dec 28 10:43:04 CET 2010


Mike B. wrote:
> Hi all,
> 
> How can I define a command which runs differently based on if an input argument was provided or not?. For example:
> 
> \mycommand
> would introduce a vsapce of 1cm
> 
> whereas 
> \mycommand{xyz}
> would print xyz
> 
> So it's conceptually something likel:
> if input argument is missing then
>    run this code
> else 
>    run this code
> endif
> 
> Season's greetings,
> Mike.

that is sadly not possible. You cannot make macros that can run as 
\macro and \macro{...}

the {} are required in both cases (or at least eting a token is required 
in both cases)

as for testing to see if #1 is empty I recommend usinf the etoolbox 
package the \ifblank{#1}{empty}{not empty} is very useful
-- 

/daleif


More information about the texhax mailing list