🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.text.tex
Article #11815

problems with optional parameters...

#11815
From: Leo Cacciari
Date: Thu, 26 Feb 1998 00:00
52 lines
2103 bytes
Hi,
  I defined some command to handle a mathematical notation of mine.
I have a lot of items who may have or have not an index, so I defined a
smart (I hope :) ) command:

\newcommand{\subscriptifnotempty}[2]{{#1\ifx#2\empty\relax\else_{#2}\fi}}

but I use it in rather a complicate fashion and ... it does't work as
espected. Here cames an example, could someone explain me WHY it doesn't
work? *&%$#@@!**

Thanks a lot.



\documentclass[12pt]{article}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{xspace}
\newcommand{\subscriptifnotempty}[2]{{#1\ifx#2\empty
                                            \relax
                                        \else
                                            _{#2}
                                        \fi}}
\newcommand{\Set}[2][\empty]{\ensuremath{\subscriptifnotempty{\mathsf{#2}}{#1}}\xspace}

\newcommand{\Mname}[2][\empty]{\ensuremath{\subscriptifnotempty{\mathbf{#2}}{#1}}\xspace}

\newcommand{\INMSet}[2][\empty]{\ensuremath{{\Set{#1}{#2}}^{\text{in}}}\xspace}

\begin{document}
When I type \verb|\INMSet[\Mname{M}]{S}| I espect to obtain somethyng
like ${\mathsf{S}}_{\mathbf{M}}^{\text{in}}$ but I get
\INMSet[\Mname{M}]{S} (ie.\ ${\mathbf{M}}S^{\text{in}}$).

Why?

thanks a lot

\end{document}


--
Leo Cacciari
Dept. Informatique UFR Sciences et Techniques
Universit� de Pau
Av. de l'Universit�
F-64000 Pau
tel: +33 5 59 92 31 99
fax: +33 5 59 80 83 74
www: http://www.univ-pau.fr/~cacciari
Technical Details
Message-ID: <34F5934A.11E96BF5@univ-pau.fr>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: f9e16,e576764e3b867f51,start
X-Google-Attributes: gidf9e16,public
X-Google-Thread: 10ee61,e576764e3b867f51,start
X-Google-Attributes: gid10ee61,public
From: Leo Cacciari <leo.cacciari@univ-pau.fr>
Subject: problems with optional parameters...
Date: 1998/02/26
Message-ID: <34F5934A.11E96BF5@univ-pau.fr>
X-Deja-AN: 328867767
Content-Transfer-Encoding: 8bit
Mime-Version: 1.0
Content-Type: text/plain; charset=iso-8859-1
Organization: Universit� de Pau et des Pays de l'Adour
Newsgroups: comp.text.tex,fr.comp.text.tex