8

I'm typesetting in LaTeX, and I'd like to display a "variable" (in my case, a reference \ref{blah} to an item number in list) in roman rather than the default arabic. Is there an easy way to do this? Thanks for any pointers!

kapa
  • 77,694
  • 21
  • 158
  • 175
anon
  • 235
  • 2
  • 9

5 Answers5

3

You can try \def\theenumi{\roman{enumi}} inside an enumerate environment -- this changes both labels and refs, but you'll have to then explicitly undo it (if you want to).

AVB
  • 3,994
  • 22
  • 21
2

lowercase

\romannumeral 0\ref{blah}\relax

uppercase

\uppercase\expandafter{\romannumeral 0\ref{blah}}

Alexey Malistov
  • 26,407
  • 13
  • 68
  • 88
  • 1
    Thanks for thinking about this. I tried the first suggestion, however, and it didn't seem to work: the output is still arabic. – anon Apr 05 '10 at 15:31
  • Perhaps I can troubleshoot better if I know what the various bits of the expression are doing. What are the "0" and the "\relax" for? – anon Apr 05 '10 at 18:57
  • 1
    `0` is needed because of if `\ref{blah}` is `??` then `\romannumeral` gives an error and `\romannumeral 0??` gives `??`. `\relax` is needed because of if there are digits after `\ref{blah}` you have a wrong result. For example, if `\ref{blah}` is `1` then `\romannumeral 0\ref{blah}0` gives `x` rather than `i`. And `\romannumeral 0\ref{blah}\relax 0` gives `x0` as you wish. – Alexey Malistov Apr 06 '10 at 06:37
1

What are the references to? Usually, you would redefine how that particular counter is displayed.

For example, to change how a section number is displayed, you could use the following command:

\renewcommand\thesection{\Roman{section}}

Now, each command that internally uses \thesection will print the section number as a roman numeral.

Similar commands work for chapter, figure etc.

\roman (lowercase r) yield lowercase roman numerals.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
  • The references are to an item number in a list. I've made the item numbers output in roman using \renewcommand{\labelenumi}{(\roman{enumi})}, but this doesn't seem to carry over to references. Is there a better way of doing this? – anon Apr 05 '10 at 15:33
  • @anon: Oops, I didn’t notice the part about list items. – Konrad Rudolph Apr 05 '10 at 15:40
1

For lowercase: {\romannumeral \ref{blah}}

For uppercase: \uppercase\expandafter{\romannumeral \ref{blah}}

Etaoin
  • 8,444
  • 2
  • 28
  • 44
0

A good solution seems to me to declare

\renewcommand{\theenumi}{\roman{enumi}}
\renewcommand{\labelenumi}{(\theenumi)}

in the header and then cite by \eqref{blah} to get your (iii) for the third item. (Note that \eqref requires the amsmath package. Alternatively, write (\ref{blah}).)

Alm
  • 1
  • 1