General ⇒ How to amalgamate commands?
How to amalgamate commands?
After re-reading this thread, I still wonder, as localghost did, in which way would that make typesetting easier?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
How to amalgamate commands?
Summing up, the problem posed in the first post can be stated as follows: given a command, say \foo, which applies to single characters, find a simple way to define, for any character X, a command \fooX that behaves as \foo{X}. After seeking a solution, I conclude that the more stable (even simplest) way to do that is by defining individually each \fooX command. In fact, it seems that things, when needed, are done in the reverse order: first one has the \fooX commands, then one defines \foo so as \foo{X} acts as \fooX. At least, this is what gaius reports about the wrisym package.
In my opinion, there is no real interest in having at one's disposal the \fooX commands. Perhaps this may save some keystrokes or be helpful when doing searches in the source files (it is easier to search for \fooX than for \foo{X} and variations as \foo X, \foo <carriage return> X,...) I don't see much more applications.
Anyway, the problem is challenging and helps learn a bit more about the intricacies of TeX.
gmedina wrote: After re-reading this thread, I still wonder, as localghost did, in which way would that make typesetting easier?
In my opinion, there is no real interest in having at one's disposal the \fooX commands. Perhaps this may save some keystrokes or be helpful when doing searches in the source files (it is easier to search for \fooX than for \foo{X} and variations as \foo X, \foo <carriage return> X,...) I don't see much more applications.
Anyway, the problem is challenging and helps learn a bit more about the intricacies of TeX.
How to amalgamate commands?
Juanjo wrote: In my opinion, there is no real interest in having at one's disposal the \fooX commands. Perhaps this may save some keystrokes or be helpful when doing searches in the source files (it is easier to search for \fooX than for \foo{X} and variations as \foo X, \foo <carriage return> X,...) I don't see much more applications.
Anyway, the problem is challenging and helps learn a bit more about the intricacies of TeX.
Agreed, it's challenging. But I guess it would generate some ¿major? modifications to the parsing procedures used by TeX, or maybe not? After all, some commands allow this kind of syntax:
\newcommand{\foo}[1]{...}
and
\newcommand\foo[1]{...}
are treated equivalently.
But what if there's more than one expected token?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
How to amalgamate commands?
gmedina wrote: But I guess it would generate some ¿major? modifications to the parsing procedures used by TeX, or maybe not? After all, some commands allow this kind of syntax:
\newcommand{\foo}[1]{...}
and
\newcommand\foo[1]{...}
are treated equivalently.
But what if there's more than one expected token?
I think that the definition of the \fooX commands is just a convenience of some users, as shorthands. The parsing procedures of TeX are not affected. Likewise, if more than one token is expected as argument of the \foo command, one can apply the same principle. Try the following, which refers to the case of two tokens:
Code: Select all
\documentclass{article}
\newcommand{\foo}[2]{These are letters~\fbox{#1} and~\fbox{#2}}
\makeatletter
\@for\tempa:={A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}\do{%
\@for\tempb:={A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z}\do{%
\expandafter\edef\csname foo\tempa\tempb\endcsname{\foo{\tempa}{\tempb}}}}
\makeatother
\begin{document}
\fooAA. \fooAB. \fooAC\ldots\fooAZ\ldots \par
\fooMA. \fooMB. \fooMC\ldots\fooZZ.
\end{document}