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

Brad & Angie dallas at e49n.us
Sun Jan 4 22:50:07 EST 2009


Here are the details.  (Sorry about not providing enough information  
the first time.)  My real problem is that I need to change a macro  
parameter to uppercase, but both snippets of code produce the same  
error.  Thanks for taking a look.  Brad.

csname example
Mac 10.5.6 TeXLive2008 TeXShop2.18 PlainTeX pdfTeX

\def\brad{brad dallas}
\def\BRAD{BRAD DALLAS}
My name is \csname brad\endcsname
\vfil\eject\bye

This works to typeset:  brad dallas

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

This creates the following errors...

This is pdfTeXk, Version 3.1415926-1.40.9 (Web2C 7.5.7)
\write18 enabled.
%&-line parsing enabled.
entering extended mode
(./textest3.tex
! Missing \endcsname inserted.
<to be read again>
                \uppercase
l.10 My name is \csname\uppercase
                              {brad}\endcsname
?
! Extra \endcsname.
l.10 My name is \csname\uppercase{brad}\endcsname

?
[1{/usr/local/texlive/2008/texmf-var/fonts/map/pdftex/updmap/ 
pdftex.map}] )</us
r/local/texlive/2008/texmf-dist/fonts/type1/bluesky/cm/cmr10.pfb>
Output written on textest3.pdf (1 page, 6615 bytes).
Transcript written on textest3.log.

On Jan 4, 2009, at 5:15 PM, David Watson wrote:

> On Jan 4, 2009, at 6:47 PM, David Watson wrote:
>
>> 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.
>>
>
> Sorry, I see you are using Plain TeX; so, is the source you provided  
> the >entire< source?
>
>> 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.
>
>
>
> ----------- Please Consult the Following Before Posting -----------
> TeX FAQ: http://www.tex.ac.uk/faq
> List Reminders and Etiquette: http://www.esm.psu.edu/mac-tex/list/
> List Archive: http://tug.org/pipermail/macostex-archives/
> TeX on Mac OS X Website: http://mactex-wiki.tug.org/
> List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex
>




More information about the MacOSX-TeX mailing list