I defined myself a counter for Examples and want it to be displayed in uppercase Roman numerals.

\newenvironment*{Example}{\refstepcounter{exampleCounter}~\\ \noindent \textbf{Example\Roman{exampleCounter}}~\\ \begin{itshape}}{\end{itshape}}

This works perfectly fine, but when I am trying to reference an example, I am just recieving arabic numbers. I tried

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

(a solution I found here but this stopped working, when I needed ö,ä,ü in my text.

At first, it was not finding the lowercase references, I got to workaround by CAPSLOCKING the labels, but roman numbering is still not possible.

Working Example



\newenvironment*{Example}{\refstepcounter{exampleCounter}~\\ \noindent \textbf{Example \Roman{exampleCounter}}~\\ \begin{itshape}}{\end{itshape}}


    This is an Example, I want to reference

Arabic example \ref{EX:BLAH}    \\
Roman example \uppercase\expandafter{\romannumeral 0\ref{EX:BLAH}}


Does anyone has an idea, how to get this roman numbers back in?

  • babel is introducing the issue. Apparently it's formatting the output of \ref{EX:BLAH} in such a way that it's not understood as a number. I don't know how to fix it but someone else might. – Miguel Jun 4 '14 at 9:24
  • Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Jun 4 '14 at 20:57
  • Your working example isn't working for me. – 71GA Dec 11 '16 at 8:57

When you define a counter, LaTeX performs two actions. It creates the actual counter by assigning it to a register, but it also creates a counter representation macro. For some counter <cntr>, the latter is given by \the<cntr>. Internally, this is handled by the macro \@definecounter (from latex.ltx, with comments added):

\def\@definecounter#1{\expandafter\newcount\csname c@#1\endcsname% <- Defined \c@<cntr>
     \setcounter{#1}\z@% <------------------------------------------- Sets counter to 0
     \global\expandafter\let\csname cl@#1\endcsname\@empty% <-------- Clear/reset list \cl@<cntr>
     \global\expandafter\let\csname p@#1\endcsname\@empty% <--------- Reference prefix \p@<cntr>
     \gdef\csname the#1\expandafter\endcsname\expandafter% <--------- Sets \the<cntr>
          {\expandafter\@arabic\csname c@#1\endcsname}}%              to be \arabic{<cntr>}

So, for your purposes, the use of


LaTeX creates


(and some other stuff). By default, \the<cntr> is set to \arabic{<cntr>}. But you can redefine that the way you want to. Specifically, in your case, use \Roman{<cntr>} and use \the<cntr> elsewhere.

enter image description here


  {\refstepcounter{exampleCounter}% \begin{Example}
   \ignorespacesafterend}% \end{Example}


\noindent Here is some regular text.
This is an Example, I want to reference
This is a reference to Example~\ref{EX:BLAH}.

It's important to change \the<cntr> since that's exactly what is used when you make a \label - LaTeX stores in the label/reference the value of the last \the<cntr> that was stepped.

  • Thank you Werner, this workds absolutely fine, is perfect and comes right in time! Tried for a few days already to get a workaround, but this is perfect! This will make the CAPSLOCK workaround obsolete, right? – T-r4X Jun 4 '14 at 19:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy