GeneralTable of contents alignment problem

LaTeX specific issues not fitting into one of the other forums of this category.
Dr. Doerke
Posts: 16
Joined: Sat Dec 06, 2008 7:55 pm

Table of contents alignment problem

Post by Dr. Doerke »

I'm using

\section*{textofsectionheading}
\addtocontents{toc}{textofsectionheading}

When I generate the table of contents, the first entry appears farther to the left than do the other entries. I moved different sections around and it always happens with the first section declaration. Any ideas as to how to fix this so that all entries are aligned to the left margin? Any ideas as to what is causing this?

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Table of contents alignment problem

Post by Stefan Kottwitz »

Hi,

try:

Code: Select all

\addcontentsline{toc}{section}{textofsectionheading}
Stefan
LaTeX.org admin
Dr. Doerke
Posts: 16
Joined: Sat Dec 06, 2008 7:55 pm

Re: Table of contents alignment problem

Post by Dr. Doerke »

Thank you. It worked for me. Now why? Whether or not I understand, I am appreciative.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Table of contents alignment problem

Post by Stefan Kottwitz »

Those are just different commands with different purpose, have a look at:
Stefan
LaTeX.org admin
Dr. Doerke
Posts: 16
Joined: Sat Dec 06, 2008 7:55 pm

Re: Table of contents alignment problem

Post by Dr. Doerke »

What do I do when I want no dots and numbers using \addcontentsline ?
I can do this with other entries using \section*{textofsection}
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Table of contents alignment problem

Post by daleif »

see the tocloft package or switch to the memoir class

both have ToC configuration support
Dr. Doerke
Posts: 16
Joined: Sat Dec 06, 2008 7:55 pm

Re: Table of contents alignment problem

Post by Dr. Doerke »

I've checked the documentation and I've coded:
\usepackage{tocloft]
...
\section*{sectiontext}
\renewcommand{\@dotsep}{10000}
\addcontentsline{toc}{section}{sectiontext}

and I've tried:
\section*{sectiontext}
\renewcommand{cftXdotsep}{\cftnodots}
\addcontentsline{toc}{section}{sectiontext}

and I've tried inserting {\cftnodots} in the \addcontentsline expression
but I am not getting anywhere.

Sorry to be a persistent questioner.
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Table of contents alignment problem

Post by daleif »

the configuration applies to the \tableofcontents, thus it has to go before \tableofcontents, otherwise you will have to write it to the .toc file.
Dr. Doerke
Posts: 16
Joined: Sat Dec 06, 2008 7:55 pm

Re: Table of contents alignment problem

Post by Dr. Doerke »

The thing is I want my sections to appear in the toc with no dots and no page numbers. However I do want my subsections to appear with dots and page numbers. So I don't want nodots for the entire toc.
daleif
Posts: 199
Joined: Wed Nov 19, 2008 12:46 am

Re: Table of contents alignment problem

Post by daleif »

read the manual for tocloft again and understand the meaning of X, and by reading the manual you will learn to remove the dots for sections only.
Post Reply