[OS X TeX] PlainTeX Macro to Define Macros in Uppercase

Brad & Angie dallas at e49n.us
Mon Jan 5 01:06:02 CET 2009


I wrote an interesting macro to create some macros for me.
Essentially, \setupMCitems{abcde} creates the following macros.

\xa = \noindent\hbox to \wdx{(\hfil a\hfil)}
\xb = \noindent\hbox to \wdx{(\hfil b\hfil)}
\xc = \noindent\hbox to \wdx{(\hfil c\hfil)}
\xd = \noindent\hbox to \wdx{(\hfil d\hfil)}
\xe = \noindent\hbox to \wdx{(\hfil e\hfil)}

in order to easily create (a), (b), (c), (d), (e) all with the same  
width.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \setupMCitems{arg}
%  setup multiple choice item macros for each token in arg
%  create a macro \x<token> to typeset (token)
%  set \wdx to the width of (token)

1.  \newdimen\wdx
2.  \def\setupMCitems#1{\findwidest\/#1\end \createMCdefs\/#1\end}

3.  \def\findwidest#1{\ifx#1\end \let\next=\relax \else \let\next= 
\findwidest
4.  	\ifx#1\/ \dimen0=0pt \else \setbox0=\hbox{#1}
5.  	\ifdim\wd0>\dimen0 \dimen0=\wd0 \fi \fi \fi \next}

6.  \def\createMCdefs#1{\ifx#1\end \let\next=\relax \else \let\next= 
\createMCdefs
7.  	\ifx#1\/ \setbox0=\hbox{(\hbox to\dimen0{\hfil})} \global\wdx= 
\wd0 \else
8.  	\expandafter\gdef\csname x#1\endcsname{\noindent\hbox to 
\wdx{(\hfil#1\hfil)}}
9.  	\fi \fi \next}
	
10.  \setupMCitems{abcde}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

My problem is that I would like the definitions to be \xA, \xB, etc.  
in uppercase.
I need to change #1 on line#8 to uppercase, but
I can't figure out how to change to uppercase inside a \csname 
\endcsname.

Here is a simple example:

\def\brad{brad dallas}
\def\BRAD{BRAD DALLAS}
My name is \csname brad\endcsname
My name is \csname\uppercase{brad}\endcsname

The first produces brad dallas, while the second line raises an error.
Any help or ideas would be greatly appreciated.
Yours,
Brad.



More information about the macostex-archives mailing list