82 Comments

  1. Jo

    Do you have an idea how can customize the font size etc. of the list headings? I’ve been googling this for quite some time now without finding a solution…

    • Hi Jo,

      Try the tocloft package. Here is an example, even though an ugly one:

      \usepackage{tocloft}
      \renewcommand{\cftsecfont}{\Large\itshape}
      \renewcommand{\cftsecpagefont}{\Large\itshape}

      You can find the documentation here.

      Tom.

  2. David

    Concerning the solution for adding “Page” above the page numbers, it doesn’t work if you have a section (an abstract, for example) that appears before your toc that is numberless but included in your toc by way of:

    \section*{\centering ABSTRACT}
    \addcontentsline{toc}{section}{Abstract}

    What happens is it shows up in your toc above the word “Page” because we are tricking LaTeX into doing what we want, but really it thinks that “Page” is a section. I know there’s probably another work around for my scenario, but I thought I might bring it up. Hopefully there is a cleaner solution for formatting the toc in this way.

    By the way, I used an article document class, in case that matters.

    • Hi David,

      Thanks for sharing this. I wouldn’t necessarily add the abstract to the table of contents. However, that’s a personal decision.

      Best, Tom.

      • Anthony

        Hi Tom, thanks for all your answer … this is the only thing I need and the only question you didn’t really answered to :D
        Do you have any clue on how to do it?
        Thanks

      • You are right, I never answered that question. The solution would be to move the command that adds the word “Page” further up so that it appears before “Abstract”. Here is the code:

        \documentclass[11pt]{article}
        \usepackage{blindtext}
        \begin{document}
        \addtocontents{toc}{~\hfill\textbf{Page}\par}
        \section*{\centering Abstract}
        \addcontentsline{toc}{section}{Abstract}
        \blindtext
        \tableofcontents
        \section{A first section}
        \blindtext
        \section{A second section}
        \blindtext
        \end{document}
  3. Dear tom, I need some help. In Brazil, in the list of tables we use the word “tabela” before the number and the title of the table. That is I need to customize the way the list of table appears. Normally, Latex just show, for example:

    List of Table

    1.1 Fisrt example of table
    1.2 Second table on the first chapter

    ******

    I need to show exactly as shown in caption:

    List of table

    Table 1.1 Fisrt example of table
    Table 1.2 Second table on the first chapter

    Thanks,

    Hugo Ribeiro

    • Hello Hugo,

      To change the title, you can either load the babel package with the option portuguese or set the name manually to anything you like:

      \usepackage[portuguese]{babel}
      %\renewcommand\listtablename{Lista de Tabelas}

      To add the word tabela before the number, use the tocloft package as shown below:

      \usepackage{tocloft}
      \renewcommand{\cfttabfont}{Tabela }

      Hope that helps. Let me know if you have any other question.

      Cheers, Tom.

      • hugoleo75

        Hi Tom,

        that was exactly what I was looking for:

        \renewcommand{\cfttabfont}{Tabela }

        And then I did for the figure “lof”:

        \renewcommand{\cftfigfont}{Figura }

        They did work as I wanted.

        Thanks a lot.
        Hugo

  4. Naeem

    Hi Tom,

    Thanks a lot for your post, its really informative.

    I have a quick question. While finalising my thesis, I came across a problem of representing a range of pages for a single entry in table of contents. For instance, If I want to use a page range 1~10 for “Preliminary Pages”. I couldn’t get any useful help from the blogs.

    Can you please help me to do that.

    Best,
    Naeem

    PS: I am using LaTeX report for my thesis.

    • Hi Naeem,

      Try the following code. Everything you need to add to your document is highlighted. It adds the line manually and suppresses the standard chapter entry.

      Hope it works!

      Best, Tom.

      \documentclass[11pt]{report}
      \usepackage{blindtext}
      \usepackage{tocloft, nameref}
      \makeatletter\renewcommand{\@pnumwidth}{3em}\makeatother
      \newcommand{\nocontentsline}[3]{}
      \newcommand{\notoc}[2]{\bgroup\let\addcontentsline=\nocontentsline#1{#2}}
      \begin{document}
      \tableofcontents
      \notoc\chapter{Preliminary Pages}\label{beforeprelimpages}\egroup
      \cftaddtitleline{toc}{chapter}{%
      \protect\parbox{1em}{\thechapter} \nameref{beforeprelimpages}}%
      {\thepage\ -- \pageref{afterprelimpages}}
      \Blindtext
      \label{afterprelimpages}
      \chapter{First Test Chapter}
      \section{Test Section}
      \chapter{Second Test Chapter}
      \Blindtext
      \end{document}
  5. Krishna

    Hi Tom,
    I have been searching for a quick tip how to use a “tab” space in table of contents (between the content names). To be more precise, for instance, i have a section 1, subsection1 and a subsubsection (1, 1.1, 1.1.1). How can I get all of them displayed (at the moment I cannot see subsubsection in the TOC!!) in TOC by having an offset infront of them (like stairs)..as in your 2nd tip (add “page” above number). Thanks for your help in advance.
    BR
    Krishna

    • Hi Krishna,

      The indentation you see in my example is the normal behavior of TOC. The example below shows how to change the depth of what is included in the TOC.

      Hope it helps,
      Tom.

      \documentclass{article}
      \usepackage{tocloft}
      \setcounter{tocdepth}{3}%including subsubsection
      \begin{document}
      \tableofcontents
      \section{Section Example}
      \subsection{Subsection Example}
      \subsubsection{Subsubsection Example}
      \end{document}
      • Krishna

        Hi Tom,
        thanks for your quick reply. Today one of my clleague was help me to get TOC as i wanted. But the way you showed in your example is very simple. I will use it tomorrow in my document :).. Thanks once again.

      • Krishna

        Hi Tom,

        set counter was set to 2 in my document and now i changed it to 3 as you suggested. it worked. But what I meant for offset is “horizontal space” between contents.. and another point is, in my case somehow toc indentation was not default (as you mentioned).. donno why.. but following code solved my problem..just wanted to share.. thanks anyway

        here it is,

        \makeatletter
        \def\l@subsection{\@tocline{2}{2pt}{2pc}{}{}}
        \def\l@subsubsection{\@tocline{2}{2pt}{3pc}{}{}}
        %above 2 lines gives the offset to the table of contents.
        \makeatother

        I used 2pt to define the “vertical space b/w the contents”..it is only working for sub and subsub sections..not for sections..anytip to get vertical space b/w sections in toc ?

        thanks in advance
        BR
        Krishna

      • Hi Krishna,

        I tried to run your code, but tocline was not defined. What package or documentclass do you use? Please give a minimal working example that I can copy-paste and then typeset.

        Just by just looking at your code, what you can try is to add one more line for section, identical to the definitions for subsection and subsubsection you already have.

        \def\l@section{\@tocline{2}{2pt}{2pc}{}{}}

        Cheers, Tom.

  6. rozita

    hi
    I am going to submit final edit of my thesis. Just 1 problem i am having, plz if possible help me. I have list of figures, tables, algorithms and Abbreviations. I made successfully the list of each one those. But in table of contents i am having only the list of Tables and Figures. I am not able to show in Table of contents , the page which is included the list of Algorithms as well as page for the list of Abbreviations.
    please tell me how should be do it?
    i tried with both 8. Creating you own list of … commands but i could make properly my requirements . plz help me.
    the other problem is sorting references by alphabet, if possible give me some help for this also.
    Thanks alot in advace.

    • Hi Rozita,

      You can manually add these lists to the table of contents. Use the following code right before producing the actual list to get the page number right.

      \addcontentsline{toc}{chapter}{Algorithms}

      It seems you defined you own list of algorithms. I wrote a post on that topic, which has more details concerning how to add it to the table of contents.

      In order to help you with your second question, I would need a little more details. What package do you use, biblatex, natbib, …? Please provide a minimal working example.

      Best, Tom.

  7. tabassum

    hi Tom,
    i have inserted a table as a figure. i changed the name by
    \renewcommand{\figurename}{table}
    but how can i now change the table of content and list of figures.

    • I guess you want to remove the table from list of figures and add it to list of tables.

      First, suppressing a figure from appearing in the list of figures is done using the caption package and a starred caption:

      \usepackage{caption}
      ...
      \begin{figure}
      ...
      \caption*{Figure caption}
      \end{figure}

      Now you can manually add the table to the list of tables:

      \addcontentsline{lot}{table}{\protect\numberline{\thetable}Some caption text.}\par

      You may also have to manually increase the table counter.

      HTH, Tom.

  8. Alain Raymond

    Hey Tom, I’ve created some custom lists and I’m able to display them with no issues. The problem is, however, that I need them to be 2-level lists. The first level would be the chapters and the second would be the elements of my list. So instead of having something of this sort:

    Lemma1……..9
    Lemma2……..10

    It should be like this:

    Chapter1…………………………………..9
    Lemma1………………………………..9
    Chapter2………………………………….10
    Lemma2……………………………….10

    Have you any idea of how I could accomplish that? Thanks in advance!

    • Hi Alain,

      I did not test this, but something along the lines of the code below should do the trick.

      \let\oldchapter=\chapter
      \renewcommand{\chapter}[1]{%
      	\oldchapter{#1}
      	\addcontentsline{lem}{lemma}{\protect\numberline{Chapter \thechapter}#1}\par
      }

      It’s not a clean approach, this will not use the optional argument nor the starred version of chapter.

      I remember there is a better way though. I forgot the name and couldn’t find it just now, but if I remember correctly, there is a package which allows you to extend existing commands by adding code before or after. Maybe you have more luck finding it…

  9. Deming

    Hey Tom, i am now preparing my PhD thesis, i have several problems, I use book class.

    1. I use “algorithm2e” generate my “List of Algorithms”, and “thmtools” generate “List of Theorems”, question is how to add “Page” above page numbers for them

    2. As what you did in 8, for “List of Algorithms” and “List of Theorems”, how can we add ‘Algorithms’ and ‘Theorems’ in front of the sequence number, respectively.

    Thanks in advance!

    Deming

    • Deming

      I have solved all these problems, but have a new one, that in “List of Theorems” using “themtools” package, the space between different chapters is not the same as the space in “List of Tables”. To make it clearly, take the space between the last one of Chapter1 and the first one of Chapter2 for example, it is very closed. Any idea to change this kind of space/

      • Great! Would you mind posting your solution here?

        I figured out your first question, but the second seems more tricky.

        \addtocontents{loe}{~\hfill\textbf{Page}\par}
        \addtocontents{loa}{~\hfill\textbf{Page}\par}

        Could it be that the difference in space has something to do with the fix of your previous problem? I created a minimal working example (see below) and the spacing seems to be the same.

        \documentclass[11pt]{report}
        \usepackage{amsthm, thmtools}
        \declaretheorem{theorem}
        
        \begin{document}
        \listoffigures
        \listoftheorems
        
        \clearpage
        
        \chapter{First}
        \begin{figure}[ht]
        \centering
        \rule{4cm}{3cm}
        \caption{dummy 1}
        \end{figure}
        \begin{theorem}[dummy 1]empty\end{theorem}
        
        \chapter{Second}
        \begin{figure}[ht]
        \centering
        \rule{4cm}{3cm}
        \caption{dummy 2}
        \end{figure}
        \begin{theorem}[dummy 2]empty\end{theorem}
        \end{document}

        Cheers, Tom.

  10. sodeju

    Is there a way to increase the column offset of the section in the table of contents? The toc now looks like:

    5.20Topic Title

    Without a space between the number and the title.

  11. Ding Yuan

    Hi Tom,

    Thanks for your post. But I cannot find what I need.
    I used the following command to generate list of figures and tables.

    \tableofcontents
    \listoffigures
    \listoftables

    However I found that the figure and table captions extend beyond the A4 page space. Is there anyway to strictly control the long captions, say like a paragraph with margins and indentations? Multiple line is acceptable for me.

    Cheers

    • Hi!

      I would need to see a minimal working example showing that captions reach into the list-of-figure margins. In the simple example below, line-breaks are correctly added to long captions. In case you are using the hyperref package, see here for more information on how to fix the problem.

      \documentclass[11pt]{article}
      \usepackage{blindtext}
      \begin{document}
      \listoffigures
      \section{Figure}
      \begin{figure}[ht]
      \centering
      \rule{4cm}{3cm}
      \caption{\blindtext}
      \label{fig:default}
      \end{figure}
      \end{document}
  12. Mauro

    Hello Tom, I have a question and I hope you can help me. So the thing is that I add a list of acronyms using the nomencl package. Later I add it manually to the table of contents as your example says. However the problem is that when I modify my Acronym list (Nomenclature) in order to have it in 2 columns, then it doesn’t appear correctly in the toc (i.e. instead of having page number “ix” it appears after my chapter 1 with page number 1).

    \tableofcontents
    \listoffigures
    \listoftables
    \printnomenclature
    \addcontentsline{toc}{chapter}{Acronyms}
    

    And where I have defined the Acronyms:

    % Nomenclature
    \usepackage{nomencl}
    \makenomenclature
    \usepackage{multicol}
    \renewcommand*\nompreamble{\begin{multicols}{2}}
    \renewcommand*\nompostamble{\end{multicols}}
    \renewcommand{\nomname}{Acronyms}
    

    Is it clear what my problem is? Thank you Tom. Best regards!

    • Mauro

      This is exactly what I get as an output

      Contents…………………………………iv
      List of Figures……………………….. vii
      List of Tables………………………… viii
      1 Introduction…………………………. 1
      1.1 Motivation…………………………. 1
      1.2 Objectives…………………………. 1
      1.3 Methodology ………………………1

      Acronyms……………………………….. 1

      While in the actual documents the Acronyms sections is in page ix

      • Hi Mauro,

        I tried to reproduce your issue with the code you provided. Try adding \clearpage before you change the page-numbering to arabic (in case that’s how you do it). See the minimal example below:

        \documentclass[11pt]{report}
        
        % Nomenclature
        \usepackage{nomencl}
        \renewcommand{\nomname}{Acronyms}
        \makenomenclature
        
        \begin{document}
        \pagenumbering{roman}
        \tableofcontents
        \addcontentsline{toc}{chapter}{\listfigurename}
        \listoffigures
        \addcontentsline{toc}{chapter}{\listtablename}
        \listoftables
        \addcontentsline{toc}{chapter}{\nomname}
        \printnomenclature
        \clearpage
        
        \pagenumbering{arabic}
        \chapter{Introduction}
        \section{Motivation}
        
        \end{document}
  13. Mauro

    Ok Tom, it seems to work like that. But only if I add the \clearpage after the \listoftables and before the nomenclature. Thanks a lot!

    \tableofcontents
    \listoffigures
    \listoftables \clearpage
    \addcontentsline{toc}{chapter}{Acronyms}
    \printnomenclature
    

    best regards!

  14. Elad

    Hi Tom,
    I have a simple question though I couldn’t find an answer through google and all the tex forums. I am writing an article and am using a list of figures, as the figures page numbers will change upon publication (hopefully) I need to remove the page numbering. Up to here there is no problem if I use the tocloft package. The problem arises because I am also using the subcaption package and the two packages seem to conflict. More precisely, when I use the tocloft package the subcaptions (captions for subfigures) don’t appear in the list. I would appreciate your help in either removing the page numbering without tocloft or in having the subcaptions appear with tocloft.
    many thanks
    Elad

  15. Ganesh Sharma

    Dear Tom,
    How we can put the page numbering in TOC like

    1. Chapter’s heading 1-7
    2. Chapter’s heading 9-10
    3. Chapter’s heading 11-15

    kindly help me.
    Thank you in anticipation.

  16. Hi Tom,
    A new standard for the Table of Contents has been set in my University in which the titles must be aligned. For example:

    CONTENTS
    1 INTRODUCTION

    2 OTHER CHAPTER NAME
    2.1 SECTION
    2.1.1 Subsection
    2.1.1.1 Subsubsection

    REFERENCES

    I don’t know where to put these spaces to set this weird configuration!
    Do you have anything in mind?
    Thanks in advance!

    • Hi Barbara,

      Use the tocloft package to set these values as follows:

      \documentclass[11pt]{report}
      \usepackage{tocloft}
      
      % Remove indent
      \setlength\cftsecindent{0pt}
      \setlength\cftsubsecindent{0pt}
      \setlength\cftsubsubsecindent{0pt}
      
      % increase numwidth
      \setlength\cftchapnumwidth{3em}
      \setlength\cftsecnumwidth{3em}
      \setlength\cftsubsecnumwidth{3em}
      \setlength\cftsubsubsecnumwidth{3em}
      
      \begin{document}
      \tableofcontents
      \chapter{Chapter}
      \section{Section}
      \section{Subsection}
      \subsection{Subsubsection}
      \end{document}
      • Hi Tom,
        Thanks for the answer! I think the spaces I tryed to show in the comment are missing but you were able to get the idea! That’s what I was looking for! I’ll test this tocloft package!
        Thanks again! And best regards!

      • Hi Barbara,
        Glad to help.
        Unfortunately, the formatting doesn’t work that well in comments unless you use HTML tags. But I saw the spaces you added which helped :-).

  17. Markus Bremer

    Hello,
    I implemented your example for program code,
    but it does not INDENT the entries from the left. All my other entries in lot and lof ARE indented…what can I do? I figured it may have to do with chapter/section in \thechapter? Tried to put \indent almost everywhere and deleted \noindent in the example but it didnt work! Please help :)

    • Hi Markus,

      Thanks for your comment.
      I assume you were trying the code for “new list of…”. There was an error in my code which is fixed now. The indentation of entries can be changed the same way as for chapters/sections in table of contents, using tocloft. Assuming the code from above:

      \setlength\cftlemmanumwidth{3.5em}

      HTH, Tom.

  18. Hi Tom, really I fell very sad, I can not debug the problem, I have to customize the TOC but I can not, when I use the command \renewcommand{\cfttoctitlefont}{\hfill\normalsize\bfseries} i face error but when i used it with a new class document it works properly

    • Hard to say without seeing more of your code. My guess would be that one of the packages you load creates a conflict with tocloft. Do you load subfigure in your document? Try:

      \usepackage{subfigure}
      \usepackage[subfigure]{tocloft}

      Otherwise, I recommend to start from your “new class document” and add one package at the time to find which causes the error.

  19. Nick

    Hi Tom,

    Thank you for these blog posts, they are awesome. That said, I’ve been trying to get the tocloft package to play nice in order to implement one of the solutions proposed in the comments- to customize the lof as such:
    1 Figure 1
    2 Figure 2

    to
    Figure 1. Figure 1
    Figure 2. Figure 2
    (and same for table)
    but either some class or package is interfering with. Are there any way to manually customize the lof?

    These are my packages:

    \usepackage{array}
    %\usepackage{tocloft}
    \usepackage{epsfig}
    \usepackage{graphicx}
    \usepackage{amsmath}
    \usepackage{floatrow}
    \usepackage{hyperref}
    • Hi Nick,

      I don’t see a problem with these packages, but I would have to see the entire code. See below for an example. Cheers, Tom.

      \documentclass[11pt]{article}
      
      \usepackage{array}
      \usepackage{tocloft}
      \usepackage{epsfig}
      \usepackage{graphicx}
      \usepackage{amsmath}
      \usepackage{floatrow}
      \usepackage{hyperref}
      
      \renewcommand{\cftfigpresnum}{Figure }
      \setlength{\cftfignumwidth}{50pt}
      \renewcommand{\cfttabpresnum}{Table }
      \setlength{\cfttabnumwidth}{50pt}
      
      \begin{document}
      
      \tableofcontents
      \listoffigures
      
      \section{Some section name}
      \begin{figure}[ht]\centering\rule{\textwidth}{0.5\textwidth}\caption{Some caption text}\label{fig:some}\end{figure}
      
      \end{document}
  20. Travis

    Hello Tom,

    I’m having a spacing issue with the Table of Contents in my thesis that I can’t find a solution to elsewhere. Specifically, I want to have a single blank space between each chapter. There is no problem if the chapter has sections, but some chapters don’t have sections and in this case I’m getting two spaces between the chapter headings. As an example, the ToC might look like:

    1 INTRODUCTION

    1.1 Subsection 1
    1.2 Subsection 2

    2 BACKGROUND

     
    3 MAIN BODY

    3.1 Subsection 1
    3.2 Subsection 2

    4 CONCLUSION

    (I would like for there to be a single space between Chapters 2 and 3.)
    I apologize for not including a minimal working example – the class file was written by someone else years ago and I don’t know what’s essential. I could be wrong, but I believe the problem occurs in the following string:

    \renewcommand{\@makechapterhead}[1]{%
      \vspace*{1.0in}%
      {\doublespace \parindent \z@ \centering \normalsize
        \ifnum \c@secnumdepth > \m@ne
              \bfseries \@chapapp{} \thechapter \par
           \fi
        \interlinepenalty\@M
        \bfseries\uppercase{#1}\par\nobreak
        \vskip \li
      }}

    Thanks in advance for any help you may be able to provide.

      • Travis

        Tom,

        I was able to work it out (following the link you provided) by inserting the following on line 7 of the code I sent previously:

        \ifnum \value{chapter}=2 \addtocontents{toc}{\protect\addvspace{-12pt}} \fi

        It’s a little ad hoc, but any port in a storm. Thank you so much for your prompt reply, for pointing me in the right direction, and for your patience with my ignorance.

        -Travis

      • Hi Travis,

        Glad you found a solution that works. Thanks for posting it here!
        Btw. I wrote a short article last night, using some of the ideas I came across while looking for answers to your question :-). Glad you asked, thanks!

        Cheers, Tom

  21. Carrie

    Tom, I have been searching for a simple solution to a what I think is a common problem. For my thesis, the only numbering allowed on TOC is roman numerals for Chapter levels only. However, I needed to manage the indentions since roman numerals after VI overlap with the chapter heading. I was able to do this simply using:

    \usepackage{tocloft}
    \setlength{\cftchapnumwidth}{0.8cm}

    However, now every “addcontentsline” I used for other chapters have shortened dot fill space and dont actually reach the page number in the TOC.

    example of addcontentslines:

    \cleardoublepage
    \addcontentsline{toc}{chapter}{\normalfont LIST OF TABLES \dotfill}
    \listoftables
    
    \newpage
    \addtocontents{toc}{\contentsline {chapter}{\normalsize Chapter \hfill}{}}
    \renewcommand{\contentsname}{TABLE OF CONTENTS}
    \makeatletter
    
    \tableofcontents
    \newpage

    Do you have any idea why the \dotfill is affected by the tocloft change or what I can do to fix it?

    Thanks

    • Hi Carrie,

      Thanks for your question.

      You can automatically add LOF and LOT to the table of contents using the tocbibind package. If you do it manually, I suggest to rename the titles (like you do for TOC) and then use the name-macro in the document.

      \renewcommand{\contentsname}{TABLE OF CONTENTS}
      \renewcommand{\listtablename}{LIST OF TABLES}
      \renewcommand{\listfigurename}{LIST OF FIGURES}
      ...
      \addcontentsline{toc}{chapter}{\listtablename}
      \listoftables\clearpage
      \addcontentsline{toc}{chapter}{\listfigurename}
      \listoffigures\clearpage

      See this post for more details.

      If you like to have dots between the title and the page number for chapters in TOC, use:

      \usepackage{tocloft}
      \renewcommand{\cftchapdotsep}{\cftdotsep}

      In general, I recommend to make all global changes in the preamble.

      Let me know if you have further questions.

      HTH, Tom

  22. Mary Hudachek-Buswell

    Hey Tom,
    I have been searching all over ctan, ctex and stack exchange trying to find a solution to my thesis format issue. You were the first to directly and simply address one issue I FINALLY fixed after searching for a while.

    Here is my preamble

    \documentclass[12pt,oneside,letterpaper]{report}
    \usepackage{titlesec}
    \renewcommand{\chaptername}{CHAPTER} 
    \titleformat{\subsection}{\normalsize}{\thesubsection}{1em}{}
    \titlespacing{\subsection}{25pt}{*2.5}{*1.5}
    \renewcommand{\cftsecfont}{\bfseries}

    I have another issue I need help with in the formatting of the TOC. Currently the chapter entries look like this
    CHAPTER 1 INTRODUCTION : : : : : : : : : : : : 1
    1.1 Background and Motivation . . . . . . . . . . . . . . . . . . . . . . . 1
    CHAPTER 4 NESTED PRODUCT DECOMPOSITION OF A RANK
    STRUCTURED MATRIX : : : : : : : : : : : : 71

    I need them to look like this
    CHAPTER 1 INTRODUCTION : : : : : : : : : : : 1
    CHAPTER 4 NESTED PRODUCT DECOMPOSITION OF A RANK
    STRUCTURED MATRIX : : : : : : : : : : : : 71

    Additionally it appears that the font in the TOC for Chapters is slightly larger. I need to decrease the size.

    I am appreciate any and all assistance

  23. Mary Hudachek-Buswell

    Well it looked fine when I typed it in, the spacing appeared correct. In the second example there was to be more space (tab) between the 1 and INTRODUCTION. Likewise with the 4 and NESTED.

    • tom

      I can see the extra space. The tocloft package has commands to change how entires are typeset.

      Use \cftchapnumwidth for extra space between the chapter number and the chapter name. You might have to try what’s the right value:

      \usepackage{tocloft}
      \setlength\cftchapnumwidth{50pt}

      HTH,
      Tom

  24. Evan Langlois

    Hi All,

    I’m trying get my TOC “just right” and I’m almost there. I used LOTS of help from this forum, but I have 1 last issue. I have Appendix A and Appendix B and they show as Chapter A/B for obvious reasons (see code below). How do I change the static “Chapter” to something that changes from Chapter to Appendix as necessary? Or hack it to work like it does?

    I’m using LyX, so all this is in my preamble and the document itself is dynamically generated, but I should be able to hack stuff in where ever necessary. While I’m here, what would I replace \small with to make “Page” a bit smaller? \smaller fails and \tiny is too small!

    %
    % Table Of Contents
    %
    % "page" text on top
    \addtocontents{toc}{~\hfill\textbf{\small Page}\par}
    \usepackage{tocloft}
    % fonts in the TOC
    \renewcommand{\cftsecfont}{\bfseries}
    \renewcommand{\cftsubsecfont}{\small}
    \renewcommand{\cftchapfont}{\large\sc\bfseries Chapter }

    … and there is the issue !

    • tom

      Thanks for this question. Using \chaptername instead of ‘Chapter’ has the advantage that it can be redefined to ‘Appendix’ as shown in the example below. Font sizes between \small and \tiny would be either \footnotesize or \scriptsize.

      \documentclass[11pt]{report}
      \usepackage{appendix}
      \addtocontents{toc}{~\hfill\textbf{\small Page}\par}
      \usepackage{tocloft}
      % fonts in the TOC
      \renewcommand{\cftsecfont}{\bfseries}
      \renewcommand{\cftsubsecfont}{\small}
      \renewcommand{\cftchapfont}{\large\sc\bfseries}
      \renewcommand{\cftchappresnum}{\chaptername\space}
      \renewcommand{\cftchapnumwidth}{7em}
      
      \begin{document}
      \tableofcontents
      \chapter{First}
      \chapter{Second}
      \begin{appendices}
      \addtocontents{toc}{\protect\renewcommand\protect\chaptername{Appendix}}
      \chapter{Third}
      \end{appendices}
      
      \end{document}
      • Evan Langlois

        That worked perfectly! I’m using LyX, so I wasn’t sure how the \addtocontents would work (was hoping it wouldn’t add 2 of them because LyX already added the Appendix), but it worked great! Luckily the software was smart enough to do things right! Thank You!

  25. Monia Nielsen

    Hey Tom

    I have a problem in my ToC (using the book class) which I hope you can help me with.
    My ToC look something like this:

    Resume i

    List of Figures ii

    List of Tables iii

    Abbreviations iv

    Chapter 1 Introduction 1
    1.1 Section………………………………………. 2
    1.2 Section………………………………………. 2

    Chapter 2 Theory 3
    2.1 Section………………………………………. 4
    2.2 Section………………………………………. 4

    Chapter 3

    etc.

    I would like to decrease the spacing between my “front matter” so it becomes:

    Resume i
    List of Figures ii
    List of Tables iii
    Abbreviations iv

    Chapter 1 Introduction 1
    1.1 Section………………………………………. 2
    1.2 Section………………………………………. 2

    Chapter 2 Theory 3
    2.1 Section………………………………………. 4
    2.2 Section………………………………………. 4

    Chapter 3

    etc.

    I don’t know if it makes a different, but the front matter have all been made with the
    \chapter*{} argument and the ToC, LoF and LoT have been added to the ToC by the \addcontentsline{toc}{chapter}{Chapter} format.

    -Monia

    • tom

      Easiest would be to manually remove the extra space for the first few chapters. I’m using tocbibind to add toc/lof/lot, etc. to the table of contents (toc).

      \documentclass[11pt]{book}
      \usepackage{tocbibind}
      \begin{document}
      \tableofcontents
      \addtocontents{toc}{\vspace{-0.8\baselineskip}}
      \listoffigures
      \addtocontents{toc}{\vspace{-0.8\baselineskip}}
      \listoftables
      \chapter{First chapter}
      \section{First section}
      \chapter{Second chapter}
      \section{Second section}
      \end{document}
  26. Manickam

    Hey Tom

    I used commands line given below
    \tableofcontents
    \include{Abs}
    \include{T0}
    \include{T1}
    \include{T2}

    But, I have two pages of abstract, next page top left comer, i need only abstract inserted of Contents.

    For that propose i used command line in Abs file give below
    \chapter*{Abstract}
    \addcontentsline{toc}{chapter}{Abstract}

    My Pdf look something like this:

    Contents
    Abstract 1
    List of Symbols and Abbreviations 3
    1 Introduction 4
    2 Figure 15

    Then something like this
    ______________________________________
    Abstract of first page.

    Next page top left comer i get like this

    Contents 2
    ______________________________________

    Something matter

    Thank You
    Manickam

    • tom

      I’m not sure I understand what the problem is here, sorry. Please send a minimal working example and maybe describe what you would like to be different. With that, I’ll be happy to take a look and help if I can.

      Thanks, Tom

Leave a Reply