26 Comments

  1. Giannis

    Hi Tom, I would like to ask how could we add a short table of contents which will contain only the chapters’ name.

    • Add \setcounter{tocdepth}{0} to your preamble. The tocdepth counter controls the level of headings added to TOC (0: chapter, 1: section, etc.).

  2. Hi Tom, Excellent article on TOC.
    One question I have is, is there a way to suppress the toc title, i.e. ‘Contents’ as I am already using a fancyhead

    \fancyhead[RO,RE]{\includegraphics[width=1.5cm]{logo.pdf}}

    to generate title headers and the toc title overwrites the fancyhead?

  3. Romain

    Hi Tom,

    I’m using hyperref for my TOC. The issue I have is that the link is only on the chapter title and not the whole line. Because I also would like that if I click on page number, then I’m directed to that page.

    Thanks for your support.
    Rom

    • Hi Romain,

      There is an package option which does exactly that. See the hyperref documentation for more details.

      \documentclass[11pt]{article}
      \usepackage{blindtext}
      \usepackage[linktoc=all]{hyperref}
      \begin{document}
      \tableofcontents
      \blinddocument
      \end{document}
  4. Igor

    Hi Tom, I need to obtain this on my LOF in the pdf file:

    ex: Figure 1 akudfkadgubkadjbvadivbakidbvadivblaidvblaidvblaivblai
    akbadkvibadlivbadivladivbladivladivbaldivlaihlaidbldibnl
    aivladivlaidvb……………………………………………………………..1

    I’m sorry if became a little confuse but I’m brazilian.

    Thanks

    • Hi Igor,

      You’ll have to be a little more specific what your question is about, e.g. no line-breaks in long captions. Please also give a minimal example to illustrate the problem.

      Thanks, Tom.

      • Sajjad

        I think he wants the word “Figure 1.1: A study” instead of “1.1 A study” which I am also trying to do but not yet successful.

      • tom

        Hi Sajjad,

        Thanks for the comment. Adding the following two lines does exactly what were looking for:

        \usepackage{tocloft}
        \renewcommand{\cftfigfont}{Figure }

        See here for a few more customizations.

        Best, Tom

  5. Hi Tom, I found your blog when I was looking for any answers about how not enumerate the page of lof/lot/loc? \pagestyle{empty}, \thispagestyle{empty} didn’t work as well.
    Thanks

    • Hey Ricky,

      Try the following:

      \documentclass[11pt]{report}
      
      \begin{document}
      \pagenumbering{gobble}
      \tableofcontents
      
      \listoffigures
      
      \listoftables
      \clearpage
      
      \pagenumbering{arabic}
      \chapter{Test chapter}
      \section{Test section}
      
      \end{document}
  6. James

    Hi Tom,

    I am trying to follow your example above. I want the LOF and LOT entries in the TOC to be sections. As it is below.. I get two LOF and LOT entries in the TOC (one as a section, one as a chapter) yet the hyperlink on the section entry is wrong??? Thanks

    \usepackage{tocloft}
    \newlength\mylena
    \settowidth\mylena{Figure}
    \newlength\mylenb
    \settowidth\mylenb{Table}
    \addtolength\cftfignumwidth{\mylena}
    \addtolength\cfttabnumwidth{\mylenb}
    \renewcommand\cftfigpresnum{Figure }
    \renewcommand\cfttabpresnum{Table }
    
    \tableofcontents
    \cleardoublepage
    
    \clearpage %\cleardoublepage %for openright
    \addcontentsline{toc}{section}{\listfigurename}
    \listoffigures
    \clearpage %\cleardoublepage %for openright
    \addcontentsline{toc}{section}{\listtablename}
    \listoftables
    \clearpage %\cleardoublepage %for openright
    • Hi James,

      Thanks for this question. You can use a little trick, by adding phantomsection before addcontentsline, the links are set properly.

      Best, Tom

      \documentclass[11pt]{report}
      \usepackage{tocloft}
      \usepackage{hyperref}
      
      \begin{document}
      
      \tableofcontents
      \cleardoublepage
      
      \clearpage %\cleardoublepage %for openright
      \phantomsection
      \addcontentsline{toc}{section}{\listfigurename}
      \listoffigures
      \clearpage %\cleardoublepage %for openright
      \phantomsection
      \addcontentsline{toc}{section}{\listtablename}
      \listoftables
      \clearpage %\cleardoublepage %for openright
      
      \end{document}
  7. James

    Great thanks Tom. I now have an issue with the sectioning…. The chapters are labeled correctly e.g Chapter 1, Chapter 2…
    But the sections are also labelled section 1, section 2 … not section 1.1, 1.2

    Weirdly the subsections are labelled 1.1 and the figures/tables are also labelled 1.1,1.2 etc

    Would really appreciate any help

    \usepackage[nottoc]{tocbibind}    % Potentially important for sectioning
    
    \renewcommand\thesection{\arabic{section}}  % very important for structure ?
    \pagenumbering{roman}
    \doublespacing
    \baselineskip=15.5pt
    
    \tableofcontents
    \cleardoublepage
    
    \listoffigures
    \cleardoublepage
    
    \listoftables
    \cleardoublepage
    
    \baselineskip=20pt
    \pagenumbering{arabic}
    \renewcommand{\chaptermark}[1]{\markboth{\chaptername\ \thechapter:\ #1}{}}
    \renewcommand{\sectionmark}[1]{\markright{\S\thesection\ #1}}
    
    \renewcommand\thesection{\arabic{chapter}}
    • Hi James,

      It’s the second line of your code where you define sections to be labeled with just the section number instead of chapter and section. Also, delete the last line. I’m not sure why you change it there. Commenting it out should fix the problem. Alternatively, you could replace it with:

      \renewcommand\thesection{\thechapter.\arabic{section}}

      Also, please provide a full minimal working example next time. It’s much easier to reproduce your issue that way.

      Cheers, Tom.

  8. Pierre-Philippe Combes

    Hi Tom,
    Very useful post!
    I’ve an extra question. I have a pretty long table of contents that fits on one page and a few lines more on a second page. But spaces between each item are pretty large.
    Is there a way to reduce them, or an instruction to tell tex to fit the table of contents in one page only?
    Thank you very much.
    Pierre-Philippe

    • tom

      Hi Pierre-Philippe,

      If it’s only a few lines, you might use the spacing package:

      %Preamble
      \usepackage{setspace}
      
      %Document
      \begin{spacing}{0.9}
      \tableofcontents
      \end{spacing}

      Possibly a more satisfying alternative is to use the tocloft package and play with, for example, the space before each chapter entry.

      %Preamble
      \usepackage{tocloft}
      \setlength\cftbeforechapskip{6pt}

      Even if there was a way, I wouldn’t recommend forcing TeX to fit the ToC on a single page. What if you decide to add two more chapters a few weeks later…?

      HTH, Tom

  9. J.D.

    Hi, Tom,

    I’m a bit new to this and have had trouble applying these ideas to my table of contents — perhaps because mine is un-numbered? I’m using the book (AMS) document class and have tocloft, and as of now, the “part” and “chapter” entries in the table of contents are set to the same indentation level. I want to make things more obvious and have the “part” entries not indented, but the “chapter” entries intended a bit. Is there any way to do this? I’ve tried throwing some things into the Preamble that I thought might work, but I keep getting error messages about “}” not being there, or there being too many.

    If you have any ideas, it would be greatly appreciated!
    Thanks!
    ~J.D.

    • tom

      Hi J.D.,

      Thanks for your comment. It seems the ams document classes are not compatible with tocloft. But what you can do is manually redefine how ToC entries are typeset. Here is a MWE to change the chapter indentation:

      \documentclass{amsbook}
      \makeatletter
      \renewcommand{\l@chapter}{\@tocline{0}{3pt plus2pt}{10pt}{1.5pc}{}}
      %@tocline arguments
      %#1: sectioning level (chapter=0)
      %#2: vertical space before the entry
      %#3: indent of the entry (default 0pt)
      %#4: space for number
      %#5: style commands (e.g., font type/size)
      \makeatother
      \begin{document}
      \tableofcontents
      \part{First}
      \chapter{First chapter}\section{Some section}
      \chapter{Second chapter}\section{Some section}
      \part{Second}
      \chapter{First chapter}\section{Some section}
      \chapter{Second chapter}\section{Some section}
      \end{document}

      Hope this helps,
      Tom

    • tom

      Here is an example:

      \documentclass[11pt]{memoir}
      \renewcommand{\cftfigurefont}{Figure }
      \begin{document}
      \listoffigures
      \chapter{Some chapter}
      \section{Some section}
      \begin{figure}[ht]
      \centering
      \rule{0.4\linewidth}{0.4\linewidth}
      \caption{Some caption}\label{fig:def}
      \end{figure}
      \end{document}

      Please consider the memoir class documentation for more details.

      • Sajjad

        Thank you for your reply. But using \cftfigurefont requires me using the tocloft package. When i use that package the format of my table of contents changes which I can’t afford to do. Can I do it it without using tocloft package?? Please help.

      • tom

        This doesn’t require the tocloft package. The tocloft command is \cftfigfont. Memoir provides a lot of flexibility by implementing commands that are provided by packages for the standard classes. Just give the code I posted a try…

  10. Sajjad

    you are asking me to change the class. But that will change the whole format of my thesis which I have compiled according to my university guidelines. Currently I am using a class “ThesisMtech” which I have modified according to my need. I am just not able to get this “Figure 1.1″ in place of “1.1″ in list of figures and list of tables. Have been trying this for 15 days now. Kindly provide some solution. I can attach my class file if you want. Thank you.

    • tom

      For some reason I thought you were using the memoir class. I wonder if using tocloft and change the lof/lot style according to your needs might work.

      Please prepare a minimal working example and a pointer to where I can get the ThesisMtech class file (ideally the one you modified) and I’ll see what I can do.

      Best, Tom

Leave a Reply