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 a document divided into \part \chapter \section and \subsection. I have 3 parts and in each part I reset all the counters.

I want that, when I do a crossref to something that is in the 1st part, chapter 3 and section 5, that LaTeX prints something like I-3.5, but I don't want that in the tableofcontents part that LaTeX prints the part number. For example, what I want is:

Part I

chapter 1 section 1.1 section 1.2

chapter 2

AND NOT

chapter I-1 section I-1.1 section I-1.2

chapter I-2

The command that I've tried

\renewcommand{\thechapter}{\thepart-\arabic{chapter}}
\renewcommand{\thesection}{\thechapter.\arabic{section}}

does exactly what I've said

Can anyone help me?

share|improve this question
add comment

1 Answer 1

The macro \p@<counter> is added as prefix for references, thus the following should do the trick:

\documentclass{book}

\makeatletter
\@addtoreset{chapter}{part}
\renewcommand*{\p@chapter}{\thepart-}
\renewcommand*{\p@section}{\thepart-}
\renewcommand*{\p@subsection}{\thepart-}
\makeatother

\begin{document}
\ref{sec:firstfirstfirst} and \ref{sec:firstfirstsecond}
\tableofcontents
\part{First part}
\chapter{First chapter in first part}
\section{First section in first chapter in first part}
\label{sec:firstfirstfirst}
\part{Second part}
\chapter{First chapter in second part}
\section{First section in first chapter in second part}
\label{sec:firstfirstsecond}
\end{document}
share|improve this answer
    
Thank you very much –  Rui Martins Oct 9 '12 at 16:51
add comment

Your Answer

 
discard

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.