I use \tableofcontents to generate a ToC of a book. It uses Roman numerals I, II, III for parts, and Arabic numerals 1, 2, 3 for chapters. I would like it to say "Part I" rather than "I", and "Chapter 23" rather than "23". How can I change this consistently throughout the document?

-
AFAIR tocloft can do this – daleif May 10 '11 at 11:20
@daleif: Can you not port the memoir toc setup to toclof. It does not look if Peter Wilson is going to get around to do that. This is a very old FAQ and there are not realy a good solution besides memoir and amsbook. – Danie Els May 10 '11 at 13:50

You can use the tocloft package. A little example (feel free to adapt it according to your needs):

\documentclass{book}
\usepackage{tocloft}
\newlength\mylenprt
\newlength\mylenchp
\newlength\mylenapp

\renewcommand\cftpartpresnum{\partname~}
\renewcommand\cftchappresnum{\chaptername~}
\renewcommand\cftchapaftersnum{.}

\settowidth\mylenprt{\cftpartfont\cftpartpresnum\cftpartaftersnum}
\settowidth\mylenchp{\cftchapfont\cftchappresnum\cftchapaftersnum}
\settowidth\mylenapp{\cftchapfont\appendixname~\cftchapaftersnum}

\setlength\cftpartnumwidth{\mylenprt}
\setlength\cftchapnumwidth{\mylenchp}

\begin{document}
\tableofcontents
\mainmatter

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

\appendix
\addtocontents{toc}{% NB!!! must be inside the first \include
\protect\renewcommand\protect\cftchappresnum{\appendixname~}%
\protect\setlength{\cftchapnumwidth}{\mylenapp}}%

\chapter{First Appendix}

\end{document}


EDIT: changed the "manual" names "Part" and "Chapter" to \partname and "\chaptername".

EDIT: changed to properly handle appendixes

-
And what about appendixes? – Danie Els May 10 '11 at 12:56
@Danie Els: you are right; I've edited my code to use \partname and \chaptername which should handle appendices if the \backmatter command is used. – Gonzalo Medina May 10 '11 at 13:04
Nope, you have redefine \cftchappresnum inside a \addtocontents. This causes a new set of problems when you use \include because of latex's immediate and delayed write mechanisms. The only foolproof solution is memoir or amsbook – Danie Els May 10 '11 at 13:25
Typo in comment. Should have been: you have to redefine .... – Danie Els May 12 '11 at 1:48