home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / text / tex / 14213 < prev    next >
Encoding:
Text File  |  1992-12-15  |  2.0 KB  |  64 lines

  1. Path: sparky!uunet!europa.asd.contel.com!howland.reston.ans.net!usc!news.service.uci.edu!unogate!mvb.saic.com!info-tex
  2. From: hamlin@aps.org (Chris Hamlin 2369)
  3. Newsgroups: comp.text.tex
  4. Subject: hyphen in math
  5. Message-ID: <9212152047.AA28011@lancelot>
  6. Date: Tue, 15 Dec 92 15:47:05 -0500
  7. Organization: Info-Tex<==>Comp.Text.Tex Gateway
  8. X-Gateway-Source-Info: Mailing List
  9. Lines: 53
  10.  
  11. >>
  12. >>
  13. >> >From: <gilligan@central.bldrdoc.gov>
  14. >> >Subject: Re: hyphen in math mode
  15. >> >
  16. >> >   I wanted to print a normal hyphen in a complex math formula. I even tried
  17. >> >
  18. >> >   \edef\hm{-}
  19. >> >
  20. >> >   outside math but in all my attemts I got math minus instead. Can someone
  21. >> >   help me with this problem?
  22. >> >
  23. >> >Try \hbox{-}, as in $x - y\hbox{-}z$.
  24. >>
  25. >> This will not allow the hyphen to change sizes in sub/superscripts. I'd use
  26. >> {\rm-} as in $A_{y{\rm-}x}$. I do not use the NFSS, so I don't know if it
  27. >> will handle this properly.
  28.  
  29. I don't think that {\rm-} will give a hyphen. It doesn't in my quick test.
  30. \mathcode`\-="2200 is used in plain and latex, and sets the - char to come
  31. out from family 2, the cmsy family (you can't get it from the rm font in math).
  32. To get the - to scale you need some tricks. Here is some code defining a \text
  33. macro for use with the OFSS. It allows you to use \it also. A short test follows
  34. the macro:
  35.  
  36. \def\text#1{\relax
  37. \mathchoice {\hbox{\everymath{\displaystyle}\rm #1}}%
  38.             {\hbox{\everymath{\textstyle}\rm #1}}%
  39.             {\hbox{\everymath{\scriptstyle}%
  40.               \def\prm{\fam\z@ \the\scriptfont\z@ \relax}%
  41.               \def\pit{\fam\itfam \the\scriptfont\itfam \relax}%
  42.               \rm #1}%
  43.             }%
  44.             {\hbox{\everymath{\scriptscriptstyle}%
  45.               \def\prm{\fam\z@ \the\scriptscriptfont\z@ \relax}%
  46.               \def\pit{\fam\itfam \the\scriptscriptfont\itfam \relax}%
  47.               \rm #1}%
  48.             }%
  49. }
  50.  
  51. $$ foo-bar ^{foo-bar} \text{foo-bar} ^{\text{foo-bar}} $$
  52.  
  53. \bye
  54.  
  55. >> >
  56. >> >---Jon
  57. >>
  58. >> Dan Luecking
  59. >>
  60.  
  61. My question: is there an easier/better way to do this?
  62.  
  63. C.Hamlin, mis@aps.org
  64.