[OS X TeX] ifthenelse and an empty value

Ueliisa ueliisa at gmx.net
Wed Apr 27 09:07:37 CEST 2005


Thanks Maarten

now I understand it better
the final fix was that I did not use \usepackage{ifthen} so it always 
throw an error
after use it I could fix with your both discussion step by step  :-))

so next time I ask first witch packages I have to include

I tried to make \acronym easier to use without write things 2 times,
spectial for acronyms with alphanumeric letters

here my finale code:
**************************
\documentclass{article}
     \usepackage{ifthen}
     \usepackage[style=altlist,toc]{glossary}
     \makeglossary

\newcommand{\myacronym}[4][]{%
     \ifthenelse{\equal{#1}{}}%
     {\newacronym{#2}{#3}{name={#2},description={#4}} }%
     {\newacronym[#1]{#2}{#3}{name={#2},description={#4},sort=#1} }%
}

% some sample acronymes
% ********************************
     \myacronym{param}{param3}{param4}
     \myacronym[optional]{param-02}{param3}{param4}
     \myacronym[cmd]{last 20. cmd}{param3}{param4}
     \myacronym[zmd]{1th cmd}{param3}{param4}

\begin{document}
     \zmd \\
     \param 3param\\
     \optional 4param\\
     \cmd \\
   \printglossary
\end{document}







On 27.04.2005, at 00:36, Maarten Sneep wrote:

> On 26 apr 2005, at 21:59, Ueliisa wrote:
>
>> Thanks Maarten
>>
>> I quickly tried your tip. But it works only with 3 parameters. I 
>> tried change parameter araoun and set the 4. as first or last  ...???
>
> try this simple example:
>
> \documentclass{article}
> \newcommand{\mycommand}[2][default value]{the first parameter: ``#1'' 
> and the second parameter: ``#2''}
> \begin{document}
>
> \mycommand{test}
>
> \mycommand[optional test]{more test}
>
> \end{document}
>
> I hope this makes it clear how to handleoptional parameters. While it 
> is possible to handle optional parameters at the end of the parameter 
> list, it isn't easy, and would strongly recommend you don't try it.
>
>> Can you help my again - hat I missunderstand?
>
> The references mailed to the list yesterday contain all this material, 
> and were written over a much longer time than anything
>
>>
>> \newcommand{\myacronym}[4][]{%
>>     \ifthenelse{\equal{#1}{}}%
>>     {\newacronym{#2}{#3}{name=#3~(#2),description=#4}}%
>>     {\newacronym[#4]{#4}{#1}{#2}{name=#2~(#1),description=#3}}%
>> }
>
> Wrong, wrong: the [4] in \newcommand{\blah}[4]{...} indicates already 
> that there are four parameters, no argument list as in many other 
> programming languages. When _using_ the command, you have to specify 
> the argument (obviously). I hope this remark, together with the sample 
> will help you enough, because I can't really figure out from this code 
> what you want to do.
>
> 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>
>
>

--------------------- 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 macostex-archives mailing list