Table of Contents Numbering

1,696 views
Skip to first unread message

gilmour-page

unread,
May 22, 2011, 11:36:04 PM5/22/11
to LaTeX Users Group
Hello,

Does anyone know of a way to manually set the page numbers in a table
of contents? I'm not actually typing the rest of the document in
LaTeX. I'm not too picky about the document class needed. I can
manually generate a TOC with \addcontentsline{toc}{type}{text} but all
the page numbers are the same. Any ideas?

Peter Flynn

unread,
May 23, 2011, 4:20:06 AM5/23/11
to latexus...@googlegroups.com

Use (eg)  \setcounter{page}{42} before each \addcontentsline, and \clearpage after.

///Peter


--
You received this message because you are subscribed to the Google Groups "LaTeX Users Group" group.
To post to this group, send email to latexus...@googlegroups.com.
To unsubscribe from this group, send email to latexusersgro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/latexusersgroup?hl=en.

gilmour-page

unread,
May 23, 2011, 4:06:18 PM5/23/11
to LaTeX Users Group
Hmm...that doesn't seem to work for me. If I use \setcounter before I
add each line and \clearpage after, then only the first TOC entry
appears. If I remove the \clearpage statement, then they all appear
but each entry has same page number (the last one that was entered).

- Chris

On May 23, 4:20 am, Peter Flynn <anglebrac...@gmail.com> wrote:
> Use (eg)  \setcounter{page}{42} before each \addcontentsline, and \clearpage
> after.
>
> ///Peter
>
> On 23 May 2011 04:48, "gilmour-page" <chrisl...@hotmail.com> wrote:
>
> Hello,
>
> Does anyone know of a way to manually set the page numbers in a table
> of contents? I'm not actually typing the rest of the document in
> LaTeX. I'm not too picky about the document class needed. I can
> manually generate a TOC with \addcontentsline{toc}{type}{text} but all
> the page numbers are the same. Any ideas?
>
> --
> You received this message because you are subscribed to the Google Groups
> "LaTeX Users Group" group.To post to this group, send email tolatexu...@googlegroups.com.
> To unsubscribe from this group, send email tolatexusersgr...@googlegroups.com.

Peter Flynn

unread,
May 23, 2011, 7:08:04 PM5/23/11
to latexus...@googlegroups.com
On Mon, May 23, 2011 at 9:06 PM, gilmour-page <chri...@hotmail.com> wrote:
Hmm...that doesn't seem to work for me. If I use \setcounter before I
add each line and \clearpage after, then only the first TOC entry
appears. If I remove the \clearpage statement, then they all appear
but each entry has same page number (the last one that was entered).

I'm sorry, I was working in haste. With no text they are empty pages, so \clearpage won't do anything. This should do what you want:

\documentclass{report}
\newcommand{\chap}[2]{\refstepcounter{chapter}\setcounter{page}{#2}%
  \addcontentsline{toc}{chapter}{\protect\numberline{\thechapter}#1}%
  \null\clearpage}
\newcommand{\sect}[2]{\refstepcounter{section}\setcounter{page}{#2}%
  \addcontentsline{toc}{section}{\protect\numberline{\thesection}#1}%
  \null\clearpage}
\newcommand{\ssect}[2]{\setcounter{page}{#2}%
  \addcontentsline{toc}{section}{#1}%
  \null\clearpage}
\begin{document}
\tableofcontents
\ssect{Preface}{1}
\chap{Introduction}{13}
\sect{Background}{20}
\sect{Development}{33}
\sect{Plans}{42}
\chap{Research}{57}
\sect{Desk research}{62}
\sect{Internet research}{73}
\addtocontents{toc}{\bigskip}
\ssect{References}{85}
\ssect{Index}{91}
\end{document}

///Peter

gilmour-page

unread,
May 23, 2011, 10:19:31 PM5/23/11
to LaTeX Users Group
That should work great. Thanks for your help!

- Chris

On May 23, 7:08 pm, Peter Flynn <anglebrac...@gmail.com> wrote:
Reply all
Reply to author
Forward
0 new messages