# Re: Defining a control sequence with uppercase roman numerals

Jellby <me@xxxxxxxxxxx> wrote:

But I can't find the way to do it with uppercase numerals, even though
exercise 7.9 is a hint. I tried with:

\newcommand{\mycommand}{\csname
myhiddencommand\uppercase\expandafter{\romannumeral\number\mytype}\endcsname}

This is more tricky, because \uppercase cannot be used inside \csname.

But you are using LaTeX, thus you can use \@Roman that is expandable,
because it explicitly looks for the limited range of roman letters and
replaces them by the uppercase variants:

| \def\@Roman#1{\expandafter\@slowromancap\romannumeral #1@}
| \def\@slowromancap#1{\ifx @#1% then terminate
| \else
| \if i#1I\else\if v#1V\else\if x#1X\else\if l#1L\else\if
| c#1C\else\if d#1D\else \if m#1M\else#1\fi\fi\fi\fi\fi\fi\fi
| \expandafter\@slowromancap
| \fi
| }

The result:
\makeatletter
\newcommand{\mycommand}{%
\csname myhiddencommand\@Roman{\mytype}\endcsname
}
or
\newcommand{\mycommand}{%
\@nameuse{myhiddencommand\@Roman\mytype}%
}%

and all kinds of \string, \expandafter and \noexpand I could think of (I
don't really understand them, you'd have noticed), to no avail. Is there
(of course there is, but how?) a way to get it?

If \@Roman cannot be used, then \uppercase helps, but it must be
used outside of \csname:

\newcommand{\@exch}[2]{#2#1}

\newcommand{\mycommand}{%
\uppercase\expandafter{%
\expandafter\csname
\expandafter\@exch\expandafter{%
\romannumeral\mytype
}%
}%
{myhiddencommand}%
\endcsname
}

Yours sincerely
Heiko <oberdiek@xxxxxxxxxxxxxxx>
.

• Follow-Ups:
• References: