home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / text / tex / 11144 < prev    next >
Encoding:
Text File  |  1992-09-11  |  1.9 KB  |  76 lines

  1. Newsgroups: comp.text.tex
  2. Path: sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!convex!constellation!wildcat.ecn.uoknor.edu!wszczepo
  3. From: wszczepo@wildcat.ecn.uoknor.edu (Witold Szczeponik)
  4. Subject: Re: detecting missing arguments in latex
  5. Sender: usenet@constellation.ecn.uoknor.edu (Usenet Administrator)
  6. Message-ID: <1992Sep11.201211.29920@constellation.ecn.uoknor.edu>
  7. Date: Fri, 11 Sep 1992 20:12:11 GMT
  8. References: <6725@vtserf.cc.vt.edu>
  9. Organization: Engineering Computer Network, University of Oklahoma, Norman, OK, USA
  10. Lines: 64
  11.  
  12. In article <6725@vtserf.cc.vt.edu> gbol@rglnext.geol.vt.edu (Gregory Lampshire) writes:
  13. >
  14. >
  15. >I want to set up a macro where the presence of an argument will be  
  16. >significant, that is
  17. >
  18. >\newcommand\fig[3]{
  19. >    \if <argument #1 is null> do this etc.
  20. >    \else etc.
  21. >    \fi
  22. >}
  23. >
  24. >
  25. >\fig{}{}{this is a phrase}
  26. >
  27. >is different from
  28. >
  29. >\fig{2}{3}{this is a phrase}
  30. >
  31. >
  32. >
  33. >How do I test to see if an argument is null?  I tried
  34. >
  35. >
  36. >\csname the #1 \endcsname but that naturally didn't work since the  
  37. >argument is not a counter, register etc..
  38. >
  39. >
  40.  
  41. I ran into the same problem some days ago.  Here's a piece of the
  42. code that tests whether the first argument is empty or not:
  43.  
  44.    {\setbox0=\hbox{\ignorespaces#1\unskip\relax}%
  45.     \ifdim \wd0=0pt%
  46.        % do whatever you want if the argument is empty
  47.     \else%
  48.        % do whatever you want if it isn't
  49.     \fi%
  50.    }%
  51.  
  52. I'm not a TeXpert, but it works fine for me.
  53.  
  54. >
  55. >
  56. >--
  57. >Gregory Lampshire 
  58. >Virginia Tech NeXT CC
  59. >Bradley Department of Electrical Engineering
  60. >gbol@rglnext.geol.vt.edu (NeXTmail welcome)
  61. >------------------------
  62. >My opinions are my very own and do not reflect the opinions of any  
  63. >employer
  64.  
  65.  
  66. ------
  67.  
  68. wszczepo@mailhost.ecn.uoknor.edu
  69. witold@eis.cs.tu-bs.de
  70.  
  71. ------
  72.  
  73. C:  A middle-level programming language which combines the power
  74.     of assembly language with the readability of assembly language.
  75.  
  76.