Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 5 down vote accepted

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".)

share|improve this answer
Thank you for the detailed answer. –  UniQP Apr 23 at 8:58

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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