home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.text.tex
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!convex!constellation!wildcat.ecn.uoknor.edu!wszczepo
- From: wszczepo@wildcat.ecn.uoknor.edu (Witold Szczeponik)
- Subject: Re: detecting missing arguments in latex
- Sender: usenet@constellation.ecn.uoknor.edu (Usenet Administrator)
- Message-ID: <1992Sep11.201211.29920@constellation.ecn.uoknor.edu>
- Date: Fri, 11 Sep 1992 20:12:11 GMT
- References: <6725@vtserf.cc.vt.edu>
- Organization: Engineering Computer Network, University of Oklahoma, Norman, OK, USA
- Lines: 64
-
- In article <6725@vtserf.cc.vt.edu> gbol@rglnext.geol.vt.edu (Gregory Lampshire) writes:
- >
- >
- >I want to set up a macro where the presence of an argument will be
- >significant, that is
- >
- >\newcommand\fig[3]{
- > \if <argument #1 is null> do this etc.
- > \else etc.
- > \fi
- >}
- >
- >
- >\fig{}{}{this is a phrase}
- >
- >is different from
- >
- >\fig{2}{3}{this is a phrase}
- >
- >
- >
- >How do I test to see if an argument is null? I tried
- >
- >
- >\csname the #1 \endcsname but that naturally didn't work since the
- >argument is not a counter, register etc..
- >
- >
-
- I ran into the same problem some days ago. Here's a piece of the
- code that tests whether the first argument is empty or not:
-
- {\setbox0=\hbox{\ignorespaces#1\unskip\relax}%
- \ifdim \wd0=0pt%
- % do whatever you want if the argument is empty
- \else%
- % do whatever you want if it isn't
- \fi%
- }%
-
- I'm not a TeXpert, but it works fine for me.
-
- >
- >
- >--
- >Gregory Lampshire
- >Virginia Tech NeXT CC
- >Bradley Department of Electrical Engineering
- >gbol@rglnext.geol.vt.edu (NeXTmail welcome)
- >------------------------
- >My opinions are my very own and do not reflect the opinions of any
- >employer
-
-
- ------
-
- wszczepo@mailhost.ecn.uoknor.edu
- witold@eis.cs.tu-bs.de
-
- ------
-
- C: A middle-level programming language which combines the power
- of assembly language with the readability of assembly language.
-
-