Hi all,
I'm using documentclass{revtex4} and am using \part{titles} to section my document. I would like these to show up in the table of contents (which they do) with pages numbers (which they do not).
Examples of use are:
\part{title}
this gives:
<part number> title (no page number)
in the TOC
\part*{Preface}
\addcontentsline{toc}{part}{Preface to next}
this gives:
Preface to next (no page number)
in the TOC
but if I do:
\part*{Preface}
\addcontentsline{toc}{section}{Preface to next}
this gives:
Preface to next <page number>
in the TOC
With this knowledge, I went to the toc file and changed {part} with {section} in all instances, then ran latex ONCE. This pulls in the page numbers for the part headings in the TOC, but obviously rewrites the toc file with the old {part} types, (not to mention making the part headings the same font size as section headings), so this is not a robust solution.
Does anyone know if there is a way to get page numbers of parts to show up in the table of contents without changing the toc sectioning type?
Thanks all.
Page Layout ⇒ Adding "Part" heading page numbers to TOC
NEW: TikZ book now 40% off at Amazon.com for a short time.
Adding "Part" heading page numbers to TOC
Hi,
you could use the titletoc package (a companion to the titlesec package) to format the entries for parts, as the following example suggests:
Remarks: 1) in the code above I incorporated some of the modifications discussed in this other thread.
2) Of course, my code is just an example. Feel free to adapt it according to your needs.
you could use the titletoc package (a companion to the titlesec package) to format the entries for parts, as the following example suggests:
Code: Select all
\documentclass{revtex4}
\usepackage{titletoc}
\renewcommand\partname{Chapter}
\renewcommand\thepart{\arabic{part}}
\renewcommand\thesection{\thepart.\arabic{section}}
\titlecontents{part}
[0em]
{\addvspace{10pt}\large\bfseries\contentsmargin{.8em}}
{\contentslabel{2.3em}}
{}
{\titlerule*[1pc]{.}\contentspage}
[\addvspace{10pt}]
\makeatletter
\def\part{\par
\addvspace{4ex}%
\@afterindentfalse
\secdef\@part\@spart}%
\def\@part[#1]#2{%
\@ifnum{\c@secnumdepth >\m@ne}{%
\refstepcounter{part}%
\addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
}{%
\addcontentsline{toc}{part}{#1}%
}%
\begingroup
\parindent \z@ \center
\interlinepenalty\@M
\@ifnum{\c@secnumdepth >\m@ne}{%
\Large\bfseries\partname~\thepart%
\par\nobreak%
}{}%
\Large\bfseries
#2%
\markboth{}{}\par
\endgroup
\nobreak
\vskip 3ex
\@afterheading
}%
\def\@spart#1{{\parindent \z@ \raggedright
\interlinepenalty\@M
\Large\bfseries
#1\par}
\nobreak
\vskip 3ex
\@afterheading}
\makeatother
\begin{document}
\tableofcontents
\part{Dummy part one}
\section{Section one one}
\section{Section one two}
\part{Dummy part two}
\section{Section two one}
\section{Section two two}
\end{document}
2) Of course, my code is just an example. Feel free to adapt it according to your needs.
1,1,2,3,5,8,13,21,34,55,89,144,233,...