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

  1. Newsgroups: comp.text.tex
  2. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!news.duc.auburn.edu!ducvax.auburn.edu!hank
  3. From: hank@ducvax.auburn.edu
  4. Subject: Re: need help with a LaTeX macro
  5. Message-ID: <1992Sep7.093726.1@ducvax.auburn.edu>
  6. Lines: 56
  7. Sender: usenet@news.duc.auburn.edu (News Account)
  8. Nntp-Posting-Host: ducvax
  9. Organization: Auburn University, AL
  10. References: <dak.715093340@tabaqui> <1992Sep07.081446.192@infko.uucp>
  11. Date: Mon, 7 Sep 1992 14:37:26 GMT
  12. Lines: 56
  13.  
  14. In article <1992Sep07.081446.192@infko.uucp>, benz@infko.uni-koblenz.de 
  15. (Hartmut Benz) writes:
  16. >>[...]
  17. >> >\newcommand{\type}[1]{\verb"#1"\\}
  18. >
  19. > As far as I know it is impssible to use \verb... inside a macro like this  
  20. > at all.
  21.  
  22. There have been several recent posts on this subject. Arseneau's response
  23. follows. 
  24.  
  25. --darrel hankerson hank@ducvax.auburn.edu
  26.  
  27.  
  28. From: asnd@reg.triumf.ca (Donald Arseneau)
  29. Subject: Re: Help writing a macro that expands to \verb
  30. Summary: How: \def\term#1{\verb|#1|}
  31. Keywords: Macro \verb Latex
  32. Date: Wed, 2 Sep 1992 09:43:00 GMT
  33.  
  34.  
  35. In article <1992Sep1.123134.7107@cs.cornell.edu>, raman@cs.cornell.edu 
  36. (T. V. Raman) writes...
  37. >I would like to have a macro of the following type:
  38. >\term#1 which expands to \verb|#1| but do not know how to write it.
  39. >Clearly \def\term#1{\verb|#1|} is not the solution.
  40.  
  41. Haven't there been a lot of requests like this lately?
  42. Here's how:
  43.  
  44. \def\term#{% not #1 but just #
  45.    \afterassignment\Term \let\TErm= }% remove {. final space is necessary
  46.  
  47. There's more. How to do the rest depends on how braces should be treated.
  48.  
  49. If:  \term{a{b} should give \verb"a{b" then use:
  50.  
  51. \edef\Term{\noexpand\verb \string}}
  52.  
  53. If:  \term{a{b}} should give \verb"a{b}" then use:
  54.  
  55. \def\Term{\bgroup \tt \let\do\@makeother \dospecials \makeactbraces}
  56.  
  57. \begingroup
  58. \catcode`\(=\catcode`\{ \catcode`\{=\active
  59. \catcode`\)=\catcode`\} \catcode`\}=\active
  60. \gdef\makeactbraces(\catcode`\{=\active \catcode`\}=\active
  61.   \edef{(\bgroup\string{)\edef}(\egroup\string}))
  62. \endgroup
  63.  
  64. That's it.  \term cannot be used in the argument to another command, 
  65. just like \verb.
  66.  
  67. Donald Arseneau        asnd@reg.triumf.ca
  68.  
  69.