home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.text.tex
- Path: sparky!uunet!haven.umd.edu!darwin.sura.net!news.duc.auburn.edu!ducvax.auburn.edu!hank
- From: hank@ducvax.auburn.edu
- Subject: Re: need help with a LaTeX macro
- Message-ID: <1992Sep7.093726.1@ducvax.auburn.edu>
- Lines: 56
- Sender: usenet@news.duc.auburn.edu (News Account)
- Nntp-Posting-Host: ducvax
- Organization: Auburn University, AL
- References: <dak.715093340@tabaqui> <1992Sep07.081446.192@infko.uucp>
- Date: Mon, 7 Sep 1992 14:37:26 GMT
- Lines: 56
-
- In article <1992Sep07.081446.192@infko.uucp>, benz@infko.uni-koblenz.de
- (Hartmut Benz) writes:
- >>[...]
- >> >\newcommand{\type}[1]{\verb"#1"\\}
- >
- > As far as I know it is impssible to use \verb... inside a macro like this
- > at all.
-
- There have been several recent posts on this subject. Arseneau's response
- follows.
-
- --darrel hankerson hank@ducvax.auburn.edu
-
-
- From: asnd@reg.triumf.ca (Donald Arseneau)
- Subject: Re: Help writing a macro that expands to \verb
- Summary: How: \def\term#1{\verb|#1|}
- Keywords: Macro \verb Latex
- Date: Wed, 2 Sep 1992 09:43:00 GMT
-
-
- In article <1992Sep1.123134.7107@cs.cornell.edu>, raman@cs.cornell.edu
- (T. V. Raman) writes...
- >I would like to have a macro of the following type:
- >\term#1 which expands to \verb|#1| but do not know how to write it.
- >
- >Clearly \def\term#1{\verb|#1|} is not the solution.
-
- Haven't there been a lot of requests like this lately?
- Here's how:
-
- \def\term#{% not #1 but just #
- \afterassignment\Term \let\TErm= }% remove {. final space is necessary
-
- There's more. How to do the rest depends on how braces should be treated.
-
- If: \term{a{b} should give \verb"a{b" then use:
-
- \edef\Term{\noexpand\verb \string}}
-
- If: \term{a{b}} should give \verb"a{b}" then use:
-
- \def\Term{\bgroup \tt \let\do\@makeother \dospecials \makeactbraces}
-
- \begingroup
- \catcode`\(=\catcode`\{ \catcode`\{=\active
- \catcode`\)=\catcode`\} \catcode`\}=\active
- \gdef\makeactbraces(\catcode`\{=\active \catcode`\}=\active
- \edef{(\bgroup\string{)\edef}(\egroup\string}))
- \endgroup
-
- That's it. \term cannot be used in the argument to another command,
- just like \verb.
-
- Donald Arseneau asnd@reg.triumf.ca
-
-