# Get both the chapter and section of a referenced section

I have chapters numbered with roman numerals and sections numbered with arabic numbers (starting from 1 for each new section, i.e. section I.3, section II.3, section III.3 - and so on - are all just displayed as "section 3").

I had to format my thesis in this way to comply to the guidelines of the Faculty and I did that by including these line in the preamble:

\renewcommand{\chaptername}{Capitolo}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand*\thesection{\arabic{section}}


Yet, given that - for example - section II.3 is labelled \label{sec:chap2sec3}, I'd like to have in the text something like "see section II.3" when in the code I write "see section \ref{sec:chap2sec3} (instead of just "see section 3" as I get at the moment).

What would be the easiest way to achieve this? Thanks in advance!

• Package \cleveref and \cref{sec:chap2sec3}, but your labelling scheme is not really useful, in my point of view. As soon as the order of your sections etc. change sec3 isn't sec3 any longer. – user31729 Mar 11 '17 at 16:55
• Seee also for an example of more sophisticated approaches: tex.stackexchange.com/questions/353491/… – user31729 Mar 11 '17 at 16:57
• Apparently I'm confused about something. Does "external pressures" mean "must have chapters numbered with roman numerals and sections numbered with arabic numbers"? Or does "external pressures" mean "must have these three specific lines in the preamble"? Or something else? – Teepeemm Mar 11 '17 at 22:52
• @teepeemm I edit the text, hope it's clearer now! – lucia de finetti Mar 11 '17 at 23:03

Here's the quick and dirty method, by changing the \p@section reference formatting macro to be prepended with \thechapter. and combining it with cleveref.

Note: \setcounter{section}{100} is just for testing purposes.

\documentclass{book}

\renewcommand{\chaptername}{Capitolo}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand*\thesection{\arabic{section}}

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

\usepackage{cleveref}

\begin{document}

\chapter{Other chapter}

\chapter{Foo}

\setcounter{section}{100}
\section{Foo section} \label{Foosection}

\end{document}


Update The version without cref

\documentclass{book}

\renewcommand{\chaptername}{Capitolo}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand*\thesection{\arabic{section}}

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

\begin{document}

\chapter{Other chapter}

\chapter{Foo}

\setcounter{section}{100}
\section{Foo section} \label{Foosection}

\end{document}

• Is there a reason to prefer this over \renewcommand{\thesection}{\thechapter.\arabic{section}}? – Teepeemm Mar 11 '17 at 17:16
• @Teepeemm: You will find the reason in the question. Don't blame me for requests done by O.P. or thesis boards or whatever ;-) – user31729 Mar 11 '17 at 17:17
• @ChristianHupfer Thanks very much! I don't understand the need for the "\setcounter{section}{100}" line: infact, what I wanted is best achieved by eliminating it. Only problem is that, instead of e.g. "I.3", "section I.3" is displayed when I write "\cref{label:chap2sec3}". How can I eliminate the word "section"? – lucia de finetti Mar 11 '17 at 18:02
• @luciadefinetti: The \setcounter{section}{100} was just for testing purposes. And your question says see section II.3 ... so \cref{...} does explicitly add the word section to it. If you don't need this, don't write see section II.3 in your question ;-) Replace \cref by the ordinary \ref then. – user31729 Mar 11 '17 at 18:09
• Thanks very much @ChristianHupfer and, yes, my mistake! :-) – lucia de finetti Mar 11 '17 at 18:10