herndon@sctc.com (William R. Herndon) (08/17/90)
I am curious as to why, in the design of TeX/LaTeX, no character exists that can be used as a seperator in the names of macros. After reading the TeXBook section on character codes and classes, I thought that the hypen would be the character to use. After all it can be used in labels ( using the \label \ref commands ), and is not called out as a reserved character. Well, I was wrong. After defining about 500 macros, all of which had hyphens in them to help improve the readability of the names, I discovered much to my dismay that TeX obviously does accord some special meaning to the hyphen character and won't allow definitions with the hyphen in them. So now what am I to do. There appearantly exists no character that can be used as a seperator, and I need one for clarity. I guess that I've learned my lesson and will no longer take anything that the TeXBook states at face value again. Arrrggggghhhhhhh!!!!! - Max ------------------------------------------------------------------------------- William R. Herndon Secure Computing Technology Corp. The opinions expressed are mine, ALL MINE! HEH, HEH, herndon@sctc.com HEH, HEH!!! (612) 482-7431
charlie@milton.u.washington.edu (Charles Geyer) (08/17/90)
In article <1990Aug16.214657.16764@sctc.com> herndon@sctc.com (William R. Herndon) writes: > I am curious as to why, in the design of TeX/LaTeX, no character > exists that can be used as a seperator in the names of macros. Because that's the way it is. The reason might have been to make $\alpha-z$ make sense. Or it might not. > After reading the TeXBook section on character codes and classes, I > thought that the hypen would be the character to use. After all it > can be used in labels ( using the \label \ref commands ), and is not > called out as a reserved character. But \label and \ref are LaTeX, not plain TeX. Why would you expect TeX command sequences to obey the rules that are allowed for LaTeX labels? > Well, I was wrong. After defining about 500 macros, all of which had > hyphens in them to help improve the readability of the names, I discovered > much to my dismay that TeX obviously does accord some special meaning to > the hyphen character and won't allow definitions with the hyphen in > them. It didn't occur to test one of these macros before you typed 500 of them? > So now what am I to do. There appearantly exists no character that can > be used as a seperator, and I need one for clarity. I guess that I've > learned my lesson and will no longer take anything that the TeXBook > states at face value again. The TeXbook is the most accurate computer manual I know. Generally far more accurate that commercial software manuals. From page 7 of the TeXbook. Control sequences come in two flavors. The first kind, like {\tt\char`\\input}, is called a {\it control word;} it consists of an escape character followed by one or more {\it letters,} followed by a space of by something besides a letter. (\TeX\ has to know where the control sequence ends, so you must put a space after a control word if the next character is a letter. For example, if you type `{\tt\char`\\inputMS}', \TeX\ will naturally interpret this as a control word with seven letters.) In case you're wondering what a ``letter'' is, the answer is that \TeX\ normally regards the 52 symbols {\tt A...Z} and {\tt a...z} as letters. The digits {\tt 0...9} are {\it not\/} considered to be letters, so they don't appear in control sequences of the first kind. A control sequence of the other kind, like {\tt\char`\\'}, is called a {\it control symbol;} it consists of the escape character followed by a single nonletter. That's it. A backslash and one or more upper or lower case letters or a backslash and a single character. Nothing else can be a control sequence. How could it be stated any clearer? > Arrrggggghhhhhhh!!!!! Indeed. -- charlie@stat.washington.edu (Charlie Geyer) Department of Statistics, University of Washington
wvenable@spam.ua.oz.au (Bill Venables) (08/17/90)
In article <1990Aug16.214657.16764@sctc.com> herndon@sctc.com (William R. Herndon) writes: > [ ... ] After defining about 500 macros, all of which had hyphens in them > to help improve the readability of the names, I discovered much to my > dismay [ ... ] On the other hand it does recognize case, and whitespace may be used very liberally. If you are very keen to enhance the readibility of your raw TeX file why not capitalize the first letter of each multi-word (MultiWord) macro and just splash the old whitespace around in creative ways? > > So now what am I to do. Ditch 99% of your macros and use LaTeX. And don't cheat. I used to use TeX that way, too - write a macro for every conceivable purpose. However six years down the track I have come to realize that this is *not* the way to go. What you end up with is your own, generally very inferior, LaTeX. Moreover the defaults have generally been very well thought out, ("Uncle Don knows best!"), and if you find you need a lot of macros to do things just the way you want to do them, then more often than not it is your judgment rather than that of the designers that is a fault. If you find that you really do need 500 macros to use LaTeX, or even TeX, for your purposes, then generally you would be better off using another typesetting package, (like `trough' or `WordBrilliant' or whatever :-). -- Bill Venables, Dept. Statistics, | Email: wvenable@spam.ua.oz.au Univ. of Adelaide, South Australia. | Phone: +61 8 228 5412
herndon@sctc.com (William R. Herndon) (08/17/90)
wvenable@spam.ua.oz.au (Bill Venables) writes: >On the other hand it does recognize case, and whitespace may be used very >liberally. If you are very keen to enhance the readibility of your raw TeX >file why not capitalize the first letter of each multi-word (MultiWord) >macro and just splash the old whitespace around in creative ways? >> >> So now what am I to do. >Ditch 99% of your macros and use LaTeX. And don't cheat. Nay, Nay. I've misstated my intent. I AM using LaTeX. The macros that I am defining are simple textual substitutions for sections of text that occur many times in many documents. I use the TeX \def command as opposed to the LaTeX \newcommand because of my own bad habits, but the problem with the hyphen persists. I am using the macros much as one would use a #define in the C language, mostly to save on the problem of maintaining these text sections in multiple documents. >I used to use TeX that way, too - write a macro for every conceivable >purpose. However six years down the track I have come to realize that >this is *not* the way to go. What you end up with is your own, generally >very inferior, LaTeX. I agree with you one hundred percent. BTW Thanks to all who responded. The capitalization idea, mentioned by more than one respondee, is excellent, and I will use it. - Max ------------------------------------------------------------------------------- William R. Herndon Secure Computing Technology Corp. The opinions expressed are mine, ALL MINE! HEH, HEH, herndon@sctc.com HEH, HEH!!! (612) 482-7431
spqr@ecs.soton.ac.uk (Sebastian Rahtz) (08/20/90)
That's it. A backslash and one or more upper or lower case letters or a backslash and a single character. Nothing else can be a control sequence. How could it be stated any clearer? this is utter cobblers, with all due respect. to use a character as a part of a control sequence is simply a matter of changing its catcode. the defaults of plain TeX are not all there is to life. definining a macro called \This-One calls for changing the catcode of -. It wouldnt surprise me a bit if this has repercussions, but you can do it. in TeX 3.0, you can use any of 256 characters for whatever purpose you wish. -- Sebastian Rahtz S.Rahtz@uk.ac.soton.ecs (JANET) Computer Science S.Rahtz@ecs.soton.ac.uk (Bitnet) Southampton S09 5NH, UK S.Rahtz@sot-ecs.uucp (uucp)
fj@iesd.auc.dk (Frank Jensen) (08/20/90)
In article <6433@milton.u.washington.edu> charlie@milton.u.washington.edu (Charles Geyer) writes: Path: iesd!dkuug!sunic!mcsun!uunet!snorkelwacker!usc!samsung!dali.cs.montana.edu!milton!charlie From: charlie@milton.u.washington.edu (Charles Geyer) Newsgroups: comp.text Date: 17 Aug 90 01:55:42 GMT References: <1990Aug16.214657.16764@sctc.com> Reply-To: charlie@stat.washington.edu (Charlie Geyer) Distribution: comp Organization: UW Statistics, Seattle Lines: 64 Summary: Expires: Sender: Followup-To: In article <1990Aug16.214657.16764@sctc.com> herndon@sctc.com (William R. Herndon) writes: > I am curious as to why, in the design of TeX/LaTeX, no character > exists that can be used as a seperator in the names of macros. Because that's the way it is. The reason might have been to make $\alpha-z$ make sense. Or it might not. Why not try "\catcode`\-=11" ? (I haven't tested it.) It will screw up $\alpha-z$ though (at least if you don't have a macro named "\alpha-z" :-). Frank Jensen Department of Mathematics and Computer Science Aalborg University DENMARK
t-rayc@microsoft.UUCP (Raymond CHEN) (08/21/90)
In article <FJ.90Aug20121003@pink.iesd.auc.dk> fj@iesd.auc.dk (Frank Jensen) writes: >Why not try "\catcode`\-=11" ? (I haven't tested it.) It will screw up >$\alpha-z$ though ... It screws up much more. If you have to give TeX a negative number, the catcode of the minus sign must be 12. So not only can't you say "\hskip-\parindent" (since it'll get parsed wrong), you can't even say "\hskip -\parindent" because the catcode of the `\- is wrong. -- Common TeXhacker mistake #15: Forgetting to say \expandafter in \expandafter\def\csname sf2451\endcsname{...}
spqr@ecs.soton.ac.uk (Sebastian Rahtz) (08/22/90)
In article <1990Aug17.130009.19044@sctc.com> herndon@sctc.com (William R. Herndon) writes:
with the hyphen persists. I am using the macros much as one would use
a #define in the C language, mostly to save on the problem of maintaining
these text sections in multiple documents.
well there is a simple answer then - use the C preprocessor! it would
work as well for TeX source as for C source.
BTW Thanks to all who responded. The capitalization idea, mentioned by
more than one respondee, is excellent, and I will use it.
your original request is easily answered. the following test file
demonstrates - used in a macro name dependent on \makedashletter and
\makedashother.
\documentstyle{article}
\begin{document}
\def\makedashletter{\catcode`\-=11\relax}
\def\makedashother{\catcode`\-=12\relax}
\makedashletter % turn it on
\def\Foo-Bar{hello}
\Foo-Bar % succeeds
\makedashother % turn it off
\Foo-Bar % fails
\end{document}
--
Sebastian Rahtz S.Rahtz@uk.ac.soton.ecs (JANET)
Computer Science S.Rahtz@ecs.soton.ac.uk (Bitnet)
Southampton S09 5NH, UK S.Rahtz@sot-ecs.uucp (uucp)