[OS X TeX] PlainTeX Macro to Define Macros in Uppercase
David Watson
dewatson at me.com
Sun Jan 4 19:47:18 EST 2009
On Jan 4, 2009, at 6:06 PM, Brad & Angie wrote:
> 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.
You would get a lot more help if you were to copy the error message
from your log and paste it into your message.
Oh yes, and include a minimal example including your documentclass,
extra packages needed, etc.
Otherwise we have to typeset what you have given us, and make certain
assumptions about your setup; the error messages we get may not be
helpful at all.
More information about the MacOSX-TeX
mailing list