\tableofcontents formatting/options ?

464 views
Skip to first unread message

Ivan K.

unread,
May 23, 2013, 1:49:27 PM5/23/13
to LaTeX Users Group
I using \tableofcontents for a document of about 25 pages.

(1) \tableofcontents is defaulting by starting about
1/4 down the length of the page. Is there any way
to change this, so that the table of contents starts
closer to the top?

(2) Perhaps related to (1), currently my table
of contents is two pages, with 26 entries on the first page
and one entry on the second page, which looks
quite inelegant. How can I have all entries
on the same page? There is plenty of room.

(3) Perhaps also related to (2), with that 1/4 blank page
that is the default because apparently, \tableofcontents
defaults by starting about 1/4 down the length
of page, is there any way I can put some text in
that blank area before the table of contents begins?
When I try, \tableofcontents always wants to
begin a new page. How can this behavior be over-ridden?


Thank you very much for your help.

Peter Flynn

unread,
May 23, 2013, 4:32:12 PM5/23/13
to latexusersgroup
On Thu, May 23, 2013 at 6:49 PM, Ivan K. <ivan_...@yahoo.com> wrote:
I using \tableofcontents  for a document of about 25 pages.

(1) \tableofcontents  is defaulting by starting about
1/4 down the length of the page.  Is there any way
to change this, so that the table of contents starts
closer to the top?

Redefine \tableofcontents. Copy it from another class file (eg article.cls) and paste it into your Preamble. This uses \section for the title instead of \chapter (which is what book and report use):

\makeatother
\renewcommand\tableofcontents{%
   \clearpage
    \section*{\contentsname
        \@mkboth{\MakeUppercase\contentsname}
                {\MakeUppercase\contentsname}}%
    \@starttoc{toc}}%
\makeatletter

This also makes the heading smaller, which looks better (ToC heading the size of a chapter heading just looks far too big, IMHO).

(2) Perhaps related to (1), currently my table
of contents is two pages, with 26 entries on the first page
and one entry on the second page, which looks
quite inelegant.  How can I have all entries
on the same page?  There is plenty of room.

If you do the above, that should make space.

If you want to squeeze one more line onto the page, use
\enlargethispage{\baselineskip}
 
(3) Perhaps also related to (2), with that 1/4 blank page
that is the default because apparently, \tableofcontents
defaults by starting about 1/4 down the length
of page, is there any way I can put some text in
that blank area before the table of contents begins?

What kind of text? 
 
When I try, \tableofcontents  always wants to
begin a new page.  How can this behavior be over-ridden?

Redefine \tableofcontents. But that would mean defining an alternative to \chapter too, in the case of book and report, because that space is defined inside \chapterhead, if you wanted to keep the chapter-sized heading. 

///Peter

SankhSarkar

unread,
May 24, 2013, 12:44:32 AM5/24/13
to latexus...@googlegroups.com
A query related to \table of contents.. when i compile the my report, the chapter numbers begin from 0 followed by subsections 0.1, 0.2 and so on.. how do we change it to start from 1?


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



--
Sankhadeep Sarkar

Peter Flynn

unread,
May 24, 2013, 3:58:16 AM5/24/13
to latexusersgroup

Use the book or report document class.

Ivan K.

unread,
May 28, 2013, 7:02:55 PM5/28/13
to LaTeX Users Group

Thank you very much for your response, Mr. Flynn.
Sorry I was away from my computer for the last day few days.


Peter Flynn <anglebrac...@gmail.com> wrote:
>
>
> On Thu, May 23, 2013 at 6:49 PM, Ivan K. <ivan_521...@yahoo.com> wrote:
> > I using \tableofcontents for a document of about 25 pages.
>
> > (1) \tableofcontents is defaulting by starting about
> > 1/4 down the length of the page. Is there any way
> > to change this, so that the table of contents starts
> > closer to the top?
>
> Redefine \tableofcontents. Copy it from another class file (eg article.cls)
> and paste it into your Preamble. This uses \section for the title instead
> of \chapter (which is what book and report use):
>
> \makeatother
> \renewcommand\tableofcontents{%
> \clearpage
> \section*{\contentsname
> \@mkboth{\MakeUppercase\contentsname}
> {\MakeUppercase\contentsname}}%
> \@starttoc{toc}}%
> \makeatletter
>
> This also makes the heading smaller, which looks better (ToC heading the
> size of a chapter heading just looks far too big, IMHO).

That code would not work under my latex installation. I got the
message "! You can't use `\spacefactor' in vertical mode."


> If you want to squeeze one more line onto the page, use
> \enlargethispage{\baselineskip}

I am not clear what I put this. Putting it just in front
of \tableofcontents executes, but nothing changes.

> > (3) Perhaps also related to (2), with that 1/4 blank page
> > that is the default because apparently, \tableofcontents
> > defaults by starting about 1/4 down the length
> > of page, is there any way I can put some text in
> > that blank area before the table of contents begins?
>
> What kind of text?

A few sentences or two, maybe. I can live without this, though.

> > When I try, \tableofcontents always wants to
> > begin a new page. How can this behavior be over-ridden?
>
> Redefine \tableofcontents. But that would mean defining an alternative to
> \chapter too, in the case of book and report, because that space is defined
> inside \chapterhead, if you wanted to keep the chapter-sized heading.


For this short document, I am not using \chapter, \section, or
\subsection.
I am just using the \addcontentsline command:

\addcontentsline{toc}{section}{this is this sections name}



Here is the situation now:

I have a total of twenty-nine \addcontentsline commands which
results in 26 entries on the table of contents on page one, and
three entries on the rest of the table of contents on page two.

These three entries on the second page however, are equally spaced
across the entire page and this just looks weird.

How can i change the default behavior a just a few \tableofcontents
lines
equally spacing across an entire page?

Thank you again for your help.

Peter Flynn

unread,
May 28, 2013, 7:44:56 PM5/28/13
to latexusersgroup
On Wed, May 29, 2013 at 12:02 AM, Ivan K. <ivan_...@yahoo.com> wrote:

Peter Flynn <anglebrac...@gmail.com> wrote:
>
> \makeatother
> \renewcommand\tableofcontents{%
>    \clearpage
>     \section*{\contentsname
>         \@mkboth{\MakeUppercase\contentsname}
>                 {\MakeUppercase\contentsname}}%
>     \@starttoc{toc}}%
> \makeatletter
>
> This also makes the heading smaller, which looks better (ToC heading the
> size of a chapter heading just looks far too big, IMHO).

That code would not work under my latex installation.  I got the
message "! You can't use `\spacefactor' in vertical mode."

I'm sorry, finger slippage. I got the \makeatother and \makeatletter the wrong way round. It should have said;

\makeatletter
\renewcommand\tableofcontents{%
  \clearpage
  \section*{\contentsname
    \@mkboth{\MakeUppercase\contentsname}
            {\MakeUppercase\contentsname}}%
  \@starttoc{toc}}%
\makeatother
 
> If you want to squeeze one more line onto the page, use
> \enlargethispage{\baselineskip}

I am not clear what I put this.  Putting it just in front
of \tableofcontents executes, but nothing changes

It should go after the \tableofcontents. Putting it before will affect the page it is on (ie the page before the table of contents).

For this short document, I am not using \chapter, \section, or \subsection.
> I am just using the \addcontentsline command:

> \addcontentsline{toc}{section}{this is this sections name}

So how are you typesetting the section title, if you aren't using \section?
This sounds like a very unreliable thing to do. Why not use \section?

> Here is the situation now:

> I have a total of twenty-nine \addcontentsline commands which
> results in 26 entries on the table of contents on page one, and
> three entries on the rest of the table of contents on page two.

\enlargethispage is probably not useful if you have three entries too many: you'd have to add far too much space. Better would be to redefine the \l@section command to leave less space between entries. 


> These three entries on the second page however, are equally spaced
> across the entire page and this just looks weird.

I don't understand "across the entire page". 
  1. Do you mean horizontally? 
  2. Or do you mean they are spaced down the page? 
  3. What command comes after \tableofcontents?
Make a miminal worked example so we can see it. Try adding \clearpage after the \tableofcontents (or after the \enlargethispage, if you use that).


> How can i change the default behavior a just a few \tableofcontents lines
> equally spacing across an entire page?

\clearpage adds vertical white-space to do this.

But better would be for you to make a minimal worked example: there may be other stuff affecting it that you have not told us about.

///Peter

Ivan K.

unread,
May 29, 2013, 1:37:38 PM5/29/13
to LaTeX Users Group

On May 28, 6:44 pm, Peter Flynn <anglebrac...@gmail.com> wrote:
>
>
> I'm sorry, finger slippage. I got the \makeatother and \makeatletter the
> wrong way round. It should have said;
>
> \makeatletter
> \renewcommand\tableofcontents{%
> \clearpage
> \section*{\contentsname
> \@mkboth{\MakeUppercase\contentsname}
> {\MakeUppercase\contentsname}}%
> \@starttoc{toc}}%
> \makeatother

And that totally works. Puts all my table of contents
entries on one page, starts the table of contents at the
top of the page. Thanks.


> > > If you want to squeeze one more line onto the page, use
> > > \enlargethispage{\baselineskip}
>
> > I am not clear what I put this. Putting it just in front
> > of \tableofcontents executes, but nothing changes
>
> It should go after the \tableofcontents. Putting it before will affect the
> page it is on (ie the page before the table of contents).

Ok, this still visually does nothing.


> > For this short document, I am not using \chapter, \section, or
> \subsection.
> > I am just using the \addcontentsline command:
>
> > \addcontentsline{toc}{section}{this is this sections name}
>
> So how are you typesetting the section title, if you aren't using \section?

Just manually. The section headings actually need to be longer
than the table of contents listing. For example, in the table of
contents
I will have:

de Ventadorn: Can vei la lauzeta mover

but in the actual section, the title will be

Bernart de Ventadorn (c. 1125 - c. 1190)
Can vei la lauzeta mover (When I See the Lark Beating)
(c. 1170?)

I don't want the entire section name in the table of contents.

> This sounds like a very unreliable thing to do. Why not use \section?

This is a short document, just about 30 pages, but it would be helpful
to have a table of contents at the beginning. Using the \chapter tag
would not be appropriate, but based on your suggestion, I substituted:

\section{this is this sections name}

for

\addcontentsline{toc}{section}{this is this sections name}

The only immediate difference is that each of the sections have a
floating point number in front of them, 0.1, 0.2, ... 0.29, 0.30.
Oh, and I get the abbreviated section name from the table of
contents in front of my fully formatted section name:

0.3 de Ventadorn: Can vei la lauzeta mover
Bernart de Ventadorn (c. 1125 - c. 1190)
Can vei la lauzeta mover (When I See the Lark Beating)
(c. 1170?)

It just seems that having this floating point number in
front of of the section headings was sort of artificial/inelegant
for a document this short. I guess that was my reason.


> > ...
> Make a minimal worked example so we can see it. Try adding \clearpage after
> the \tableofcontents (or after the \enlargethispage, if you use that).
> ...
> But better would be for you to make a minimal worked example: there may be
> other stuff affecting it that you have not told us about.

Indeed. After the header, by document begins:

\begin{document}
\normalsize
\tableofcontents

addcontentsline{toc}{section}{Perotin: Viderunt omnes}

{\Large {\bf Perotin} (fl. c. 1200)}\\
{\LARGE {\em Viderunt omnes}} {\Large (c. 1200)}\\

some text some text some text some text some text some text
some text some text some text some text some text some text

and the then the rest of the entries. What happens with the above
is that entries 1-26 are on the "table of content page 1"
entries 27-30 are on "table of contents page 2" and then my
text starts on page 2 _immediately_ after the table of contents.

I would prefer that my text start on a new page and so I add
the tag \pagebreak to my above example.

\begin{document}
\normalsize
\tableofcontents

addcontentsline{toc}{section}{Perotin: Viderunt omnes}

\pagebreak % I ADD THIS

{\Large {\bf Perotin} (fl. c. 1200)}\\
{\LARGE {\em Viderunt omnes}} {\Large (c. 1200)}\\

some text some text some text some text some text some text
some text some text some text some text some text some text


What happens now is that my actual text does begin on
page 3, the last four entries of the table of contents
are on page 2, _but_ these last four table of contents
entries are spread vertically equidistantly from
the top to the bottom. It looks most inelegant and
is difficult to read.


How can one keep a consistent spacing between the elements
of the table of contents while having my main text start on
a page after the table of contents?


Hopefully I was clear. Thank you very much for your help.

Ivan K.

unread,
May 29, 2013, 1:55:46 PM5/29/13
to LaTeX Users Group

I wrote:
>
> I would prefer that my text start on a new page and so I add
> the tag \pagebreak to my above example.
>
> \begin{document}
> \normalsize
> \tableofcontents
>
> addcontentsline{toc}{section}{Perotin: Viderunt omnes}
>
> \pagebreak % I ADD THIS
>
> {\Large {\bf Perotin} (fl. c. 1200)}\\
> {\LARGE {\em Viderunt omnes}} {\Large (c. 1200)}\\
>
> some text some text some text some text some text some text
> some text some text some text some text some text some text
>
> What happens now is that my actual text does begin on
> page 3, the last four entries of the table of contents
> are on page 2, _but_ these last four table of contents
> entries are spread vertically equidistantly from
> the top to the bottom. It looks most inelegant and
> is difficult to read.

Oh; \clearpage is what I want. Not \pagebreak.


Ole Peter Smith

unread,
May 29, 2013, 2:25:53 PM5/29/13
to latexus...@googlegroups.com
I will have:

    de Ventadorn: Can vei la lauzeta mover

but in the actual section, the title will be

   Bernart de Ventadorn (c. 1125 - c. 1190)
   Can vei la lauzeta mover (When I See the Lark Beating)
   (c. 1170?)

I don't want the entire section name in the table of contents.

\section[shortitle]{longtitle}?

0le 

--
                                            /////
                                         ( O O )
=================oOO==(_)==OOo=================
            Every day and every hour, I'm Learning more
          The more I Learn, the less I Know about before
         The Less I know, the more I want to Look around
             Diggin' deeper into Higher Ground...  UB40
                                   .oooO Oooo.
==================(     )=(     )=====================
                                     \  (     )  /
                                      \_)   (_/
===============================================
                        Ole Peter Smith, IME, UFG
            http://olepeter.mat.ufg.br  - ole at mat.ufg.br
===============================================
                   Life sure is a Mystery to be Lived
                      Not a Problem to be Solved
===============================================

Peter Flynn

unread,
May 29, 2013, 2:37:29 PM5/29/13
to latexusersgroup
On Wed, May 29, 2013 at 6:37 PM, Ivan K. <ivan_...@yahoo.com> wrote:

On May 28, 6:44 pm, Peter Flynn <anglebrac...@gmail.com> wrote:
>
>
> I'm sorry, finger slippage. I got the \makeatother and \makeatletter the
> wrong way round. 

And that totally works.  Puts all my table of contents
entries on one page, starts the table of contents at the
top of the page.  Thanks.

Cool.
 
> It should go after the \tableofcontents. Putting it before will affect the
> page it is on (ie the page before the table of contents).

Ok, this still visually does nothing.

Nor will it, now. If the page isn't full (as it isn't, now that you're using the new \tableofcontents), then enlarging the page doesn't have any effect.

In any case, it only works if you enlarge the page by enough lines to make it have an effect.
 
Just manually.  The section headings actually need to be longer
than the table of contents listing.  For example, in the table of
contents
I will have:

    de Ventadorn: Can vei la lauzeta mover

but in the actual section, the title will be

   Bernart de Ventadorn (c. 1125 - c. 1190)
   Can vei la lauzeta mover (When I See the Lark Beating)
   (c. 1170?)

I don't want the entire section name in the table of contents.

Use the form:

\section[de Ventadorn: Can vei la lauzeta mover]{Bernart de Ventadorn (c. 1125 - c. 1190)
   Can vei la lauzeta mover (When I See the Lark Beating)
   (c. 1170?)}

The optional argument is for a short form used in the ToC and for running headers (if you use them).


The only immediate difference is that each of the sections have a
floating point number in front of them, 0.1, 0.2, ... 0.29, 0.30.

You are using the book or report class. Those MUST have chapters to make the numbering work.

If you don't want to use chapters, switch to using the article class, where the topmost level is the \section.
 
front of of the section headings was sort of artificial/inelegant
for a document this short.  I guess that was my reason.

No, just using the wrong document class.
 
Indeed.  After the header, by document begins:

   \begin{document}
   \normalsize

What is that for? \normalsize is the default: you don't need to specify it.
 
   \tableofcontents

   addcontentsline{toc}{section}{Perotin: Viderunt omnes}

   {\Large {\bf  Perotin}  (fl. c. 1200)}\\
   {\LARGE {\em Viderunt omnes}} {\Large (c. 1200)}\\

There is some serious trouble here, \bf and \em are obsolete for nearly 20 years. Try this instead:

\section[\textbf{Pérotin:} \textit{Viderunt omnes}]
        {\textbf{Pérotin} (fl.\ c.~1200)\\
         \textit{\LARGE Viderunt omnes} (c.~1200)}
  1. The \Large size is the default in \section, so you don't need to specify it
  2. The optional argument gets you your ToC entry
  3. You need a soft-space {\␣} or a tie (~} after periods following lower-case characters that do not end a sentence, otherwise the space will be a sentence-space (too big)
  4. \em and \bf are obsolete and should not be used.
  5. Having a larger phrase in the middle of the section title looks odd (just an æsthetic view)
It would be very useful to those who write the documentation if you could say where you found \em and \bf because whatever document it was needs updating.

[OT: I remember recording Viderunt omnes with Musica Ficta in Exeter when I was a student there...wonderful stuff.]
 
and the then the rest of the entries.  What happens with the above
is that entries 1-26 are on the "table of content page 1"
entries 27-30 are on "table of contents page 2"

Even after changing to the new format of \tableofcontents?
 
and then my
text starts on page 2 _immediately_ after the table of contents.

Normal \tableofcontents is followed by a \chapter or something else that starts a new page automatically. You need to add \clearpage.

I would prefer that my text start on a new page and so I add
the tag \pagebreak to my above example.

No, never \pagebreak. That breaks the page without adding white-space filler.
 
What happens now is that my actual text does begin on
page 3, the last four entries of the table of contents
are on page 2, _but_ these last four table of contents
entries are spread vertically equidistantly from
the top to the bottom.  It looks most inelegant and
is difficult to read.

That's what \clearpage is for. It adds white-space filler (and flushes any pending footnotes).
 
///Peter

Ivan K.

unread,
May 29, 2013, 6:23:44 PM5/29/13
to LaTeX Users Group

On May 28, 6:44 pm, Peter Flynn <anglebrac...@gmail.com> wrote:
>
...
> > Indeed. After the header, by document begins:
>
> > \begin{document}
> > \normalsize
>
> What is that for? \normalsize is the default: you don't need to specify it.

Even if something is the default value, I like to put it in the file.
It helps keep me organized.


> > addcontentsline{toc}{section}{Perotin: Viderunt omnes}
> >
> > {\Large {\bf Perotin} (fl. c. 1200)}\\
> > {\LARGE {\em Viderunt omnes}} {\Large (c. 1200)}\\
>
> There is some serious trouble here, \bf and \em are obsolete for nearly 20
> years. Try this instead:
>
> \section[\textbf{Perotin:} \textit{Viderunt omnes}]
> {\textbf{Perotin} (fl.\ c.~1200)\\
> \textit{\LARGE Viderunt omnes} (c.~1200)}

Ok, I am now using above syntax with the article class.

Things look alright, the floating point number has now
been changed to an integer.


Is there anyway to get rid of the integer though?
I would prefer the sections to not be numbered.


> 3. You need a soft-space {\␣} or a tie (~} after periods following
> lower-case characters that do not end a sentence, otherwise the space will
> be a sentence-space (too big)

Thanks !

> 4. \em and \bf are obsolete and should not be used.
>...
> It would be very useful to those who write the documentation if you could
> say where you found \em and \bf because whatever document it was needs
> updating.

I learned those tags from the Kopka/Daley book in 1999 and have
used them ever since.


...
> That's what \clearpage is for. It adds white-space filler (and flushes any
> pending footnotes).

So I have learned.

Thank you Mr. Flynn for taking the time to help me out !

Gildas Cotomale

unread,
May 29, 2013, 6:32:38 PM5/29/13
to latexus...@googlegroups.com
> Is there anyway to get rid of the integer though?
> I would prefer the sections to not be numbered.
>
that's the purpose of stared version of sectionning commands
\section*{won't be numbered but not put in the table of contents
eitheir}


>> 4. \em and \bf are obsolete and should not be used.
>>...
>> It would be very useful to those who write the documentation if you could
>> say where you found \em and \bf because whatever document it was needs
>> updating.
>
> I learned those tags from the Kopka/Daley book in 1999 and have
> used them ever since.
>
1999 ...then not so old book... Strange it mentioned kinda internal
forms and not those authors should use...

Peter Flynn

unread,
May 29, 2013, 6:58:26 PM5/29/13
to latexusersgroup
On Wed, May 29, 2013 at 11:23 PM, Ivan K. <ivan_...@yahoo.com> wrote:

On May 28, 6:44 pm, Peter Flynn <anglebrac...@gmail.com> wrote
> What is that for? \normalsize is the default: you don't need to specify it.

Even if something is the default value, I like to put it in the file.
It helps keep me organized.

OK.
 
Ok, I am now using above syntax with the article class.

Things look alright, the floating point number has now
been changed to an integer.

It wasn't actually a floating point number. It was the chapter number and the section number separated by a full point. If you also use \subsection and \subsubsection you will get numbers like 1.1.1.1
 
I learned those tags from the Kopka/Daley book in 1999 and have
used them ever since.

Try to change to LaTeX2e. \em, \it, and \bf are not commutative: they are separate TeX (not LaTeX) fonts.
With the LaTeX2e commands, you can have \textsf{\textit{\textbf{bold italic sans-serif}}}
 
Thank you Mr. Flynn for taking the time to help me out !

No problem, I'm glad it all worked. The trick is to get LaTeX to do the work for you (I'm lazy, which is why I use LaTeX, not Word :-)

///Peter

Reply all
Reply to author
Forward
0 new messages