I have the following code


    \part{First Part}
    \chapter{First Chapter}
    \label{inner} Some text.

    \part{Second Part}
    \chapter{First Chapter}

that produces a reference 1 for the label inner. How can I include the number of the part associated with the chapter in this reference, i.e. automatically create a cross-reference of the form I.1?

1 Answer 1


The LaTeX kernel provides a nifty mechanism for "prefixing" material to cross-references to counters. For every counter variable defined somewhere via a \newcounter macro named, say, somecounter, LaTeX automatically creates an auxilliary macro named \p@somecounter, and the value of this macro is automatically prefixed to the result of a \ref command that references the counter somecounter.

By default, these auxilliary prefixing macros are empty, but it's straightforward to modify them via \renewcommand instructions. For the case at hand, you could achieve your objective by adding the instructions

\renewcommand{\p@chapter}{\thepart.} % prefix "\thepart." to the number of the chapter

to the preamble, before loading hyperref. (The \makeatletter and \makeatother instructions are needed because the macro \p@chapter contains the character @ which normally has category code "other".)


Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.