I'm trying this:

\newcommand\orule[1]{\refstepcounter{rule}\label{#1}\printrule{\therule}: }
\crefformat{rule}{#2\protect \printrule{#1}#3}
\orule{foo} Foo \\
\orule{bar} Bar \\
See \cref{foo}. \\
See \cref{foo,bar}.

I'm getting:

R1: Foo 
R2: Bar
See R1.
See ?? 1?? 2.

What is wrong? ChatGPT suggests that \crefformat{rule} should be replaced with \crefformat{Rule}, but it doesn't help :)

  • 1
    The problem vanishes if one moves the first fives lines after \begin{document} into the preamble. In particular, See \cref{foo,bar}. generates "See Rules 1 and 2."
    – Mico
    Jan 22, 2023 at 12:25
  • 1
    @Mico you are right! If you post an answer, I will gladly accept it.
    – yegor256
    Jan 22, 2023 at 12:30

1 Answer 1


My main suggestion is that you move the first five lines of code after \begin{document} into the preamble.

In addition, if you want cross-references to rules be prefaced with the letter "R" automatically, I suggest you modify the macro \therule accordingly. With this change in place, all you need to do after loading the cleveref package is to provide suitable \crefname and \Crefname directives.

enter image description here




\orule{foo} Foo.

\orule{bar} Bar.

See \labelcref{foo}. \Cref{bar} expresses\dots\ See \cref{foo,bar}.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .