[OS X TeX] ifthenelse and an empty value

Maarten Sneep maarten.sneep at xs4all.nl
Tue Apr 26 12:14:24 EDT 2005


On 26 apr 2005, at 16:54, Ueliisa wrote:

> I try to make an \newcommand that could have 3 or 4 parameters.
> With \ifthenelse I want check about is the 4. value set or not an then 
> use another command set:
>
> \newcommand{\newcmd}[4]{\ifthenelse{#4={}}{#1 - #2 - #3}{#1 - #2 - #3 
> - #4}

Better use the optional parameter as discussed before:

\newcommand{\newcmd}[4][]{%
     \ifthenelse{\equal{#1}{}}%
     {#2 - #3 - #4}%
     {#1 - #2 - #3 - #4}%
}

Note that the first parameter is what you called as #4, and if present, 
must be placed between square brackets:

\newcmd[param4]{param 1}{param 2}{param 3}{param 4} or if param 4 isn't 
given: \newcmd{param 1}{param 2}{param 3}. Note that the parameters 
shift!

Maarten

--------------------- Info ---------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
           & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Post: <mailto:MacOSX-TeX at email.esm.psu.edu>





More information about the MacOSX-TeX mailing list