1

I am using the book class and I have the following structure for my chapter and sections:

\renewcommand\thechapter{\Roman{chapter}}
\renewcommand\thesection{\arabic{section}}

so that I got for the chapter and sections

I
 1
 2
 ...
II
 1
 2
...

which is fine since I don't want to have an heavy structure with I.1, I.2, ..., II.1 in the section title and ToC.

But when I reference let say the section 1 of chapter II I would like to get as a result II.1 and not just 1 (which is confusing when I am referencing from another chapter).

Is there a way to add this chapter number automatically for the section references? I could not find satisfying answer so far.

NB: I don't know if it is of any interest but my that my figures, tables, equations are all named with the chapter number so when I ref them I have already the chapter number which is fine for me.

Thanks

2

A reference can be prefixed a the time of its definition in \label by \p@<counter>:

\makeatletter
\renewcommand*{\p@section}{\thechapter.}
\makeatother

Example:

\documentclass{book}
\renewcommand\thechapter{\Roman{chapter}}
\renewcommand\thesection{\arabic{section}}

\makeatletter
\renewcommand*{\p@section}{\thechapter.}
\makeatother

\begin{document}
\tableofcontents
\chapter{First chapter}
\label{chap:first}
\section{First section}
\label{sec:first}
\chapter{Second chapter}
\label{chap:second}
\section{Second section}
\label{sec:second}

Section \ref{sec:first} in chapter \ref{chap:first},
section \ref{sec:second} in chapter \ref{chap:second}.
\end{document}

Table of contents:

Table of contents

References:

Result

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.