Page LayoutFormatting Table of contents

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
hjbahirat
Posts: 15
Joined: Mon Jul 27, 2009 7:24 am

Formatting Table of contents

Post by hjbahirat »

Hello,
I am trying to format my table of contents in the following way :-
1 Intro
2 Second Chapter
3 Third Chapter
.
.
.
Appendix A ...
Appendix B ....
.
.
.
I tried all the options suggested in the tocloft package discussions.
I couldn't change the \cftchapnumwidth value just before the appendix.
I have a question, can the \cftchapnumwidth be changed dynamically.
Thanks in anticipation ...

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Formatting Table of contents

Post by gmedina »

Hi,

try using the titletoc package instead: you can change the format for entries in the ToC in any part of your document. Refer to the package documentation for further information.
1,1,2,3,5,8,13,21,34,55,89,144,233,...
hjbahirat
Posts: 15
Joined: Mon Jul 27, 2009 7:24 am

Re: Formatting Table of contents

Post by hjbahirat »

Thanks for the suggestion.
I got the formatted entries but those are with the command \titlecontents.
I couldn't add the word Appendix to the labels, so completely dropped the label and created the entry. Something like this

1............
...........
2............
...........

Appendix A ......
....
Appendix B......
.....

When I tried to use the \dottedcontents,the output looks like this..
1............
...........
2............
...........

A ......
....
B......
.....

And I could not add the wodk Appendix in front of A,B etc.
I got an error with \contentslabel command, but it was defined outside \titlecontents etc. Now, I don't understand whether we can define \contentslabel outside of any other main commands or it has to inside one of those \title commands.

Next problem I face is how to add the word Appendix. I think I didn't quite understand the documentation do I am trying to reread and experiment, but I appreciate any help.

Thanks ...
Himanshu
User avatar
gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Formatting Table of contents

Post by gmedina »

Hi,

the following code formats the ToC entries for appendices as you desire:

Code: Select all

\documentclass{book}
\usepackage{titletoc}

\begin{document}
\tableofcontents

\chapter{Test chapter one}

\chapter{Test chapter two}

\titlecontents{chapter}[0em]
  {\addvspace{10pt}}
  {\bfseries \contentslabel{-.5em}\contentspush{Appendix}\hspace*{2em}}
  {\bfseries}{\titlerule*[100pc]{.}\bfseries\contentspage}

\appendix
\chapter{Test appendix one}

\chapter{Test appendix two}

\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
hjbahirat
Posts: 15
Joined: Mon Jul 27, 2009 7:24 am

Re: Formatting Table of contents

Post by hjbahirat »

Hi ,
Thank you so much.
I tried it and it works just fine.

regards,
Himanshu
kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

Re: Formatting Table of contents

Post by kaiserkarl13 »

I think the tocloft package also provides this sort of functionality (in case you run into a scenario down the road where titletoc is incompatible with something or other).
Post Reply