Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Single Spacing LaTeX TOC

  1. Nov 4, 2011 #1


    User Avatar
    Gold Member

    I'm running in the report document class and I was wondering how does one make the table of contents single spaced? Or possibly even 1 1/2 spaced. I tried some suggestions involving the tocloft package and everything pretty much went to hell. Due to some annoying issues with how the theses need to be done (I hate my university), the table of contents is created by

    \chapter*{Chapter name}
    \addcontents{toc}{chapter}{Chapter name}

    Does anyone know a simple way to single space or 1 1/2 space the entries in the TOC?

    Do I need to provide anymore info?

    The style file I use has something about the table of contents as

    Code (Text):
     \fi \chapter*{TABLE OF CONTENTS\@mkboth{CONTENTS}{CONTENTS}}
    but I'm a bit clueless as to what's going on there :)
  2. jcsd
  3. Nov 4, 2011 #2

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper

    \setlength in the preamble with tocloft is the usual way to customize TOC without editing the style.

    The [itex]\LeTeX[/itex] default is single space though - oh but you have a TOC with only chapter headings?

    Code (Text):




    \chapter{Test chapter one}
    \chapter{Test chapter two}

  4. Nov 4, 2011 #3


    User Avatar
    Gold Member

    I have chapters and sections :) The thesis is mainly double spaced so I declared double spacing at the very beginning of everything.

    I really want to avoid using tocloft because the style file I'm using does it's own stuff to the table of contents. Tocloft makes my headings for the TOC, LOF, and LOT go a bit crazy.
  5. Nov 4, 2011 #4

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    It's forcing the table of contents to be single column even if the document proper is two column.

    So write your own \tableofcontents macro that uses this given table of contents command. NOTE WELL: THIS IS NOT TESTED:
    Code (Text):
  6. Nov 4, 2011 #5


    User Avatar
    Gold Member

    I assume I put that after the first part that I posted? I'm pretty clueless about latex :P

    I put it after and I noticed the TOC shifted but was still double spaced.

    Could it be because the TOC isn't being generated automatically as expected and instead is being compiled with \addcontents{toc}{chapter}{blahblahblah}?
  7. Nov 4, 2011 #6

    Simon Bridge

    User Avatar
    Science Advisor
    Homework Helper

    Oh now I get you - you want to start out single space for the toc and switch to double-space for the body. That would be quite unusual as a standard, which is probably why the style doesn't support it.

    How about set the document to single-space and :


    Then switch between different spacing options with:


    For other sizes use the \setstretch command like this:


    Double-spacing is usually only used in drafts - which is often what is requested for marking. The actual paper would use a different format.
  8. Nov 5, 2011 #7


    User Avatar
    Gold Member

    Thanks for the help guys. I just realized some code after that going as

    Code (Text):
                    \baselineskip 0.15in  % added for smaller spacing
     \def\l@section{\baselineskip 0..15in  % added for smaller spacing
     \def\l@subsection{\baselineskip 0..15in  % added for smaller spacing
     \def\l@subsubsection{\baselineskip 0.20in  % added for smaller spacing
     \def\l@paragraph{\baselineskip 0.20in  % added for smaller spacing
     \def\l@subparagraph{\baselineskip 0.20in  % added for smaller spacing
    was responsible for changing the spacing upon adding things to the TOC. I didn't really see anything that made me think it was doing anything to the TOC, but apparently it is :)
  9. Nov 5, 2011 #8


    User Avatar
    Science Advisor
    Homework Helper

    Yup, that's the right place to be. If you do
    Code (Text):

    the TOC entry is printed by the command
    Code (Text):

    There's nothing special about using format identifiers like "chapter", "section" etc, except those are what the \chapter{...} and \section{...} commands generate for free. If you want to do something really fancy (like including short chapter summaries in the contents or whatever) you might want to define some additional formats.

    The spacing of the TOC is (almost) completely independent of the spacing of the rest of the document, so \singlespace etc won't change anything.

    Look at your .toc file, then read the code of \contentsline (assuming your packages haven't renamed it as something else). \contentsline is what makes the parameter "foo" execute the command \l@foo.
    Last edited: Nov 5, 2011
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Discussions: Single Spacing LaTeX TOC