144 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 😀
        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

  27. Albert

    Hi Tom. thanks very much for your great post(s) !
    I’m just wondering, if (or how) tocloft can be used also for the “List of Algorithms”.
    I e.g., want to add the word “Algorithm” to the list, as for instance done for LOF/LOT.

    Unfortunately, simple using “\renewcommand{\cftloafont}{Algorithm }” won’t do it…

    Any idea?

    Best and thanks for your support,
    Albert

    p.s.: I’m simply adding the LOA with the standard “input-function” in LyX

    • tom

      Hi Albert,

      Yes, tocloft would be the right choice. See here for an example on how to create a list of algorithms. I’m not greatly familiar with LyX. You might have to manually add some stuff to the (LaTeX) code.

  28. Chudy Bikola

    Please, I am using the lof to show list of figures. The problem is that I want the listed figures to be left justified, starting at the same position as the heading “List of Tables”. Please, how do I do it?

    • tom

      Hi Chudy,

      How is this different from what you get by default? Please, send a minimal working example to illustrate the problem.

      Thanks, Tom

  29. trinitrocainda

    Hi tom,

    Thank you for the explanation above. But I have had troubles in removing the hanging indent in the second line after the number of the lof. I mean, I want this:

    ” Fig 23 Esta es la mayor recopilación de datos hecho por la humanidad desde
    que se aprendió a recolectar…………………………………………………………. 106″

    to look like this:

    ” Fig 23 Esta es la mayor recopilación de datos hecho por la humanidad desde
    que se aprendió a recolectar…………………………………………………………. 106″

    Please, I hope you could help me.

    Thank you

    • tom

      Hi there,

      I understand your issue. However, it is difficult for me to reproduce it without seeing your code. Please post a minimal working example and I’ll be happy to suggest a solution.

      Regards, Tom

  30. Rajesh

    Hello,

    My report contains long CHAPTER headings, FIGURE and TABLE captions.

    I am using the following commands:

    \tableofcontents
    \listoffigures
    \listoftables

    The long headings and captions going out of the page (towards the right side of the page), instead of entering the next line.

    Is there is any technique to sort out this issue? I don’t wish to use the shortened headings or captions in the table of contents page…

    I don’t wish to use the following command:

    \chapter[SHORT CHAPTER HEADING TO BE DISPLYED ON TABLE OF CONTENTS PAGE]{LONG CHAPTER NAME LONG CHAPTER NAME LONG CHAPTER NAME}

    Thank you,

    Regards,
    Rajesh

    • tom

      Hi Rajesh,

      Thanks for getting in touch. I’ve seen this question several times. Normally, headings and captions are automatically broken. Would you mind to post a minimal working example here to illustrate the problem. If I can reproduce it, I might be able to help.

      Best,
      Tom

      • Rajesh

        Hello Tom,

        Thank you very much for the quick response.

        I do get the correct display of headings and captions (in list of contents, list of figures/Tables page), when I use PDFLaTeX + View PDF.

        But, whenever I use LaTeX + Dvi->PS + PS->PDF, the long chapter headings and figure/table captions goes out of the page (towards the right margin of the page).

        Thank you.

        Have a nice day.

  31. Rajesh

    The problem is solved just by just removing the following package from the preamble:

    \usepackage{hyperref}
  32. NAJAR Tarek

    Hello Tom:
    Can you please give me information how to insert a header for each chapter containing the chapter name with a line below

  33. Alex Mwaniki Wambua

    Hi, Tom,

    Am writing my thesis but have issues with TOC. I need Chapters reflected has Chapter 1:Introduction within the text and Chapter 1 in the TOC. How do i go about this?

    • tom

      Hi Alex,

      Thanks for the question. It would have be easier for me if you provided a minimal working example, showing what you have tried so far. I came up with something following your description above. Please give it a try.

      Cheers, Tom

      \documentclass{report}
      \usepackage{titlesec,blindtext, tocloft}
      \renewcommand{\cftchappresnum}{Chapter~}
      \addtolength{\cftchapnumwidth}{2cm} %
      \titleformat{\chapter}[hang]{\Huge\bfseries}{\chaptername~\thechapter:~}{0pt}{\Huge\bfseries}
      \begin{document}
      \tableofcontents
      \chapter{Introduction}
      \blindtext
      \end{document}
  34. Alex Mwaniki Wambua

    Dear Tom;
    Thanks for the reply.
    Am actually compiling PhD thesis and it has worked very well.

    The only issue is the space between the chapter and the chapter name;

    Chapter 1 Introduction

    ???

    Back Ground

    • tom

      Hi Alex,

      To reduce space between chapter and chapter name in the contents, reduce the length. E.g.:

      \addtolength{\cftchapnumwidth}{1.5cm}

      To remove some white space between chapter title and text, use \vspace{-30pt}:

      \titleformat{\chapter}[hang]%
      {\Huge\bfseries}{\chaptername~\thechapter:~}{0pt}%
      {\Huge\bfseries}[\vspace{-30pt}]

      Hope this helps,
      Tom

  35. Alex Mwaniki Wambua

    Dear Tom;

    Am importing figure (.epn) into text BUT they are all uncolored. How can i make them colored.

    Regards
    Alex

    • tom

      I’m afraid, I’ve never heard of the .epn figure file format. If you meant .eps, it should be sufficient to load the graphcix package. Otherwise, try loading the epstopdf package in addition (see below).

      Best wishes, Tom

      \documentclass{article}
      \usepackage{graphicx,epstopdf}
      \begin{document}
      \includegraphics{figure.eps}
      \end{document}
      • Alex Mwaniki Wambua

        Thanks Tom, the format is .eps. i will try it and revert back shortly.

  36. Hi Tom!
    Is it possible to decide the margin between the list of figures and top of the page? I see huge space from list of figures to top of the page as well as the first entry of the list.

    • tom

      Hi Gaurav,

      You can remove white space in the list of figures (see code below). However, I wouldn’t recommend to do that, as it adds an inconsistency with other lists (toc, lot) and chapters in general.

      One way to remove white space before lof heading is to patch command \listoffigures, which is an unnumbered chapter, using etoolbox. I copied the code from here. To remove white space after the lof heading, simply add a negative \vspace as a list entry.

      Hope this helps!

      Cheers, Tom

      \documentclass[11pt]{report}
      \usepackage{etoolbox}
      \let\oldlistoffigures\listoffigures
      \makeatletter
      \renewcommand{\listoffigures}{%
        \patchcmd{\@makeschapterhead}{\vspace*{50\p@}}{\relax}{}{}%
        \oldlistoffigures%
        \patchcmd{\@makeschapterhead}{\relax}{\vspace*{50\p@}}{}{}%
      }  
      \makeatother
      \begin{document}
      \tableofcontents
      \clearpage
      \listoffigures
      \addtocontents{lof}{\vspace{-1.5cm}}
      \chapter{Dummy chapter}
      \begin{figure}[ht]
      \centering
      \rule{5cm}{5cm}
      \caption{Dummy figure}
      \label{fig:dummy}
      \end{figure}
      \end{document}
      • Alaa Bahamran

        I tried this code with the List of Figure and it worked great. However, when I use it with the Bibliography the word “Bibliography” appears on the last page, and it doesn’t remove the space after the heading. Any idea of a better way to do that?

      • Hi there,

        My suggestion is a similar patch as I mentioned in the comment using the etoolbox package.

        Place the following code right before the bibliography chapter:

        \makeatletter
        \patchcmd{\@makeschapterhead}{\vspace*{50\p@}}{}{}{}
        \makeatother

        See the package documentation and this thread here for more details.

        Best, Tom

  37. Brian Wyvill

    Hi Tom – very useful article! This question concerns using tocloft and subfig. I am formatting a report for a musician friend and he has a number of lists such as movie, example, diagram. How do I make submovie etc? (sorry don’t have WordPress available right now to beautify this MWE). The log file shows a lot of errors such as: LaTeX Error: No counter ‘submovie’ defined. Clearly the necessary is defined in subfig for the figure environment.

    thanks – Brian

    \documentclass[11pt]{report}
    \usepackage[T1]{fontenc}
    \usepackage{mwe}    
    \usepackage{subfig}
    \usepackage[titles,subfigure]{tocloft}
    \usepackage{newfloat}
    \newlistof{movie}{lom}{List of Movies}
    \DeclareFloatingEnvironment[name=Movie,fileext=lom]{movie}
    \renewcommand{\cftmoviepresnum}{Movie˜}
    \setlength{\cftmovienumwidth}{2cm}
    
    \textheight=8.5in
    
    \begin{document}
    %% the figure example works fine
      \begin{figure}[!ht]
        \subfloat[First sub-figure\label{subfig-1:dummy}]{%
          \includegraphics[width=0.45\textwidth]{example-image-a}
        }
        \hfill
        \subfloat[Second sub-figure\label{subfig-2:dummy}]{%
          \includegraphics[width=0.45\textwidth]{example-image-b}
        }
        \caption{figure env}
        \label{fig:dummy}
      \end{figure}
      
    % movie works fine but not in combination with subfloat
       \begin{movie}[!ht]
        \subfloat[First sub-movie\label{subfig-1:dummy}]{%
          \includegraphics[width=0.45\textwidth]{example-image-a}
        }
        \hfill
        \subfloat[Second sub-movie\label{subfig-2:dummy}]{%
          \includegraphics[width=0.45\textwidth]{example-image-b}
        }
        \caption{movie env}
      \end{movie}
    
    \end{document}
    • tom

      Hi Brian,

      That’s an interesting question. It turns out, subcaption works better with newfloat than subfig. You can find a minimal example below.

      Best,
      Tom

      \documentclass[11pt]{report}  
      \usepackage{graphicx,subcaption}
      \usepackage[titles,subfigure]{tocloft}
      \usepackage{newfloat}
      \newlistof{movie}{lom}{List of Movies}
      \DeclareFloatingEnvironment[name=Movie,fileext=lom]{movie}
      \renewcommand{\cftmoviepresnum}{Movie~}
      \setlength{\cftmovienumwidth}{2cm}
      \textheight=8.5in
      \begin{document}  
      movie works fine but not in combination with subfloat
      \begin{movie}[!ht]
        \begin{submovie}{0.45\textwidth}
          \centering\rule{3cm}{3cm}
          \caption{First sub-movie\label{subfig-1:dummy}}
        \end{submovie}\hfill
        \begin{submovie}{0.45\textwidth}
          \centering\rule{3cm}{3cm}
          \caption{Second sub-movie\label{subfig-2:dummy}}
        \end{submovie}
        \caption{movie env}
      \end{movie}
      \end{document}
  38. Nirbhow Jap Singh

    dear sir,
    you have presented a wonderful article to help the user for issues related to latex. a number of suggestions i’ve already successfully used from your article, for my work. but i have two problem related to list of figures, tables, symbols.

    First problem is that for my work i want that list of figure should appear as:

    List of Figures
    ____________________________________
    S.no. Figure name Page no.
    _____________________________________

    second problems: My list of figures, tables are long and i want that following pages should also contain
    _____________________________________
    S.no. Figure name Page no.
    _____________________________________

    • tom

      Hi there,

      Thanks for your question.

      You can add them manually on every page, similar to the response here. Or you can add it as a header which is shown here. Please give it a try and let me know if you get stuck. I’m happy to help if you provide a minimal working example.

      Cheers, Tom

  39. Colt F.

    Hi Tom,

    When I create a table of contents, the spacing between the paragraph number and paragraph title changes once the paragraph numbers have an additional digit. For example:

    3.8 Title
    3.9 Title
    3.10 Title

    Is there a way to fix this so that all paragraph titles line up?

  40. Frankline Tireito

    Hi, working on my thesis and wish to change chapter numbering in TOC be in words
    Chapter ONE: Introduction etc
    instead of Chapter 1…using report document class

  41. hello …

    I need help with TOC…

    I did add this :

    \tableofcontents
    \addcontentsline{toc}{chapter}{Contents}
    \listoffigures
    \addcontentsline{toc}{chapter}{List of Figures}
    \listoftables
    \addcontentsline{toc}{chapter}{List of Tables}

    to my document and it work nicely, but I want to reduce the space between them… is it possible?
    I tried \vspace{1 cm}, but it didn’t work… thanks

    • tom

      Hi there,

      You can use the tocloft package to add a negative vspace after every chapter toc entry:

      \usepackage{tocloft}
      \renewcommand\cftchapafterpnum{\vskip-10pt}

      Obviously, this creates issues when a chapter is followed by a section, as there the whitespace is smaller. See this Q&A for a more complex solution that fixes this issue.

      Best,
      Tom

  42. Mahmood Qureshi

    Hi I want to insert the straight horizontal line after the “LIST OF FIGURES”. I also want to capatilze it

    • tom

      Hi Mahmood,

      Please see the code below. It uses the tocloft package to add a line after the LOF heading and redefines the title.

      Best, Tom

      \documentclass[11pt]{report}
      \usepackage{tocloft}
      \renewcommand{\listfigurename}{LIST OF FIGURES}
      \renewcommand\cftafterloftitle{\par\noindent\hrulefill\par}
      \begin{document}
      \addtocontents{lof}{}
      \listoffigures
      \chapter{First}
      \begin{figure}[ht]\centering\rule{1cm}{1cm}\caption{default}\end{figure}
      \end{document}
  43. Hi i have a problem with the number 6, when i make the \addcontentsline{toc}{chapter}{Contents}
    which is in a specific number pf page, the contents appear in other numeration of page:

    \frontmatter
    ...
    \addcontentsline{toc}{chapter}{Contents}
    \tableofcontents
    \listoftables
    \listoffigures
    ...

    the page in wich the contents page appear is in Xiii but the table of contents says is in Xii, any toughs?

    • tom

      Hi there,

      Try using \clearpage after each list. For example:

      \tableofcontents\clearpage

      If that does not fix the problem, please provide a complete minimal working example so I can reproduce it.

      Best, Tom

  44. I am using tocloft to add word chapter before chapter name in TOC. The alignment of subsequent sections is not as per the requirement.

    Chapter 1 Introduction 1
    1.1 Section. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
    1.1.1 Subsection. . . . . . . . . . . . . . . . . . . . . . . . 3

    I wish to get 1.1 under I of Introduction.

    • tom

      Hi Harash,

      Thanks for you question. You can use the \cftsetindents macro to change the indent of headings. Please see the tocloft package documentation for more details. I added a minimal example below.

      Best, Tom

      \documentclass[11pt]{report}
      \usepackage{blindtext,tocloft,calc}
      \newlength\mylength
      \renewcommand\cftchappresnum{\chaptername~}
      \renewcommand\cftchapaftersnum{:}
      \settowidth\mylength{\cftchappresnum\cftchapaftersnum\quad}
      \addtolength\cftchapnumwidth{\mylength}
      \cftsetindents{section}{\cftchapnumwidth}{2.3em}
      \cftsetindents{subsection}{\cftsecnumwidth+\cftchapnumwidth}{3.2em}
      \begin{document}
      \tableofcontents
      \blinddocument
      \end{document}
  45. Konstantinos

    Hi Tom, sorry for my english, is not so good, but i hope you undersand my question. In the table of contents i try to make the number of pages clickable, so i use the command
    \usepackage[linktocpage=true]{hyperref}. The problem is that in sectionς that are unnumberd, as abstact, or the bibliography dont work. I added these sections in toc with the command \addcontentsline{toc}{section}{the bibliography}. Can you help me;

    • tom

      Hi Konstantinos,

      Thanks for your comment. I created a minimal example to reproduce your problem. In the example, I can click the page number of the “Unnumbered” section, by loading the hyperref package the way you did. Therefore, I am not sure what is going wrong in your case. Please provide a similar minimal working example to illustrate the problem.

      Thanks, Tom

      \documentclass[11pt]{article}
      \usepackage{blindtext}
      \usepackage[linktocpage=true]{hyperref}
      \begin{document}
      \tableofcontents
      \section{Numbered}
      \blinddocument
      \addcontentsline{toc}{section}{Unnumbered}
      \section*{Unnumbered}
      \blinddocument
      \end{document}
  46. maxmax2016

    Hi Tom,
    I have a question that doesn’t seem to have been covered yet.
    I have few separated files to be assembled to produce a book.
    The book must have a general index that contains the word ‘Page’ before the page number, but only for the first entry; then, starting from the second entry and for all remainings, I need the hash in place of ‘Page’. Something like this:
    First — Some title ….. Page 3
    Second — Some title .. # 10
    Third — Some title …… # 16
    and so on.
    I use this in a style file (I just write here the part of code related):

    \renewcommand{\cftpartleader}{\cftdotfill{\cftdotsep}\text{Page}}

    And this in any of the text file:

    \addcontentsline{toc}{part}{First -- Some title}

    It works fine, but I got the ‘Page’ output for all entries, of course.

    How can I change it with ‘#’ for subsequent entries?
    Any idea? Thanks a lot!

    • tom

      Hi there,

      My first intention would be to do \renewcommand{\cftpartleader} and set it to “\#” after the first part. If that doesn’t solve your problem, please provide a minimal working example.

      Best, Tom

      • maxmax2016

        Hi Tom,
        I understand what you mean, but in this way I only got only one OR the other, while I need ‘Page’ just for first one AND # for all the remaining entries.
        To better explain,
        1) I compile a container file which has a list of tex files to be assembled, in the order I need, to get a book:
        \usepackage{mystylefile}
        \begin{document}
        \tableofcontents
        \include{file-1}
        \include{file-2}
        \end{document}
        2) I use a style file for all the tex documents, which defines the index instructions routine (size, margins, spaces etc) to output it, among which the one I posted in my previous message to output ‘Page’, which is the one to be tricked:
        \renewcommand{\cftpartleader}{\cftdotfill{\cftdotsep}\text{Page}}
        3) Each tex jobs contain the \addcontentsline{toc}{part}{Something — Some title}, to trigger toc, in order to have one entry in index for each job. Simplifying, my toc has an entry for every file, containing the page number related to the whole book after appended.
        Now, I wonder how and where define that, starting from second file, I should use this:
        \renewcommand{\cftpartleader}{\cftdotfill{\cftdotsep}\#}.
        I’m thinking about a counter, but really still a nightmare.
        Thanks!

      • tom

        Hello again,

        Below is a minimal working example that illustrates a possible solution. It defines a command that prints “Part”, which is redefined to “#” and saved to the toc file after the first part.

        Best,
        Tom

        \documentclass[12pt]{book}
        \usepackage{blindtext,tocloft}
        \newcommand\partleader{\partname}
        \begin{document}
        \renewcommand{\cftpartleader}{\cftdotfill{\cftdotsep}{\large\bf \partleader}}
        \tableofcontents
        \part{First}
        \blinddocument
        \addtocontents{toc}{\protect\renewcommand\protect\partleader{\#}}
        \part{Second}
        \blinddocument
        \part{Third}
        \blinddocument
        \end{document}
  47. maxmax2016

    Thanks Tom.
    It works, but it’s a fully manual procedure.
    Is it possible to handle it in my stile file, as I told you I’m actually using, with a kinda of counter, triggered inside style itself or inside text jobs?
    Thanks

    • tom

      I see. You can extend the part command with a conditional on the part counter. This code can be moved to the style file. The minimal example only covers numbered parts. If you have unnumbered parts, google for “custom chapter latex” and implement it accordingly.

      HTH, Tom

      \documentclass[12pt]{book}
      \usepackage{blindtext,tocloft}
      \newcommand\partleader{\partname}
      \renewcommand{\cftpartleader}{\cftdotfill{\cftdotsep}{\large\bf \partleader}}
      \let\stdpart\part
      \renewcommand\part[1]{%
      \stdpart{#1}
      \ifnum\value{part}=1%
      	\addtocontents{toc}{\protect\renewcommand\protect\partleader{\#}}
      \fi
      }
      \begin{document}
      \tableofcontents
      \part{First}
      \blinddocument
      \part{Second}
      \blinddocument
      \part{Third}
      \blinddocument
      \end{document}
  48. Carla

    Hello, currently I have the code below and I would like to increase the space between the number and the text in the list of figures, any idea how to do this?

    \usepackage{listings}
    \usepackage{titletoc}
    
    \contentsuse{lstlisting}{lol}
    \titlecontents{lstlisting}[1.5em]
    {\addvspace{0.6pc}}
    {\text{\thecontentslabel} }
    {}
    {\titlerule*[0.7em]{$\cdot$}\contentspage}
    []
    • Hi Carla,

      Thanks for your comment. You can increase the space between the number and the text through the tocloft package. See the package documentation for more details.

      Best, Tom

      \usepackage{tocloft}
      \setlength\cftfignumwidth{3em}
  49. Rasoul

    Hi Tom,

    May I ask you please to let me know how to equalize the spaces between figure\table headings of different chapters in the list?

    It, by default, adds a space before and after headings of new chapters.

    Your feedback would be a great help to me.

    Thanks

    • Hi Rasoul,

      Thanks for your comment. Could you provide a minimal working example? This will help me to suggest a possible solution.

      Best, Tom

  50. Brolin

    Hi Tom,
    I am new to latex. I managed to make my page numbers look in the format {section number}-{page number}.
    Example: If I have section going from page 1 to page 3. It will be numbered as 1-1, 1-2, 1-3.
    I did this by using “\setcounter{page}{1}” command. But the same page number does not appear in the TOC. TOC looks like the following

    Section 1 ……………………………. 1
    subsection…………………………. 2
    Section 2 ……………………………… 1
    subsection………………………….. 2
    subsection……………………………3

    My Question is, how do I format the page number in TOC?

    • Hi Brolin,

      What you did is change the actual counter value. What you actually want is to change the way the counter value is printed. LaTeX uses the macro \thecounter to do that. See the minimal example below.

      Best, Tom

      \documentclass[11pt]{article}
      \usepackage{blindtext}
      \renewcommand{\thepage}{\arabic{section}-\arabic{page}}
      \begin{document}
      \tableofcontents
      \blinddocument
      \end{document}
  51. Hi Tom,
    I would love your thoughts on the following problem.
    I wanted to remove any bold-facing from the table of contents page. So that all headings and sub-headings appear in regular font. To do so, I used the following:

    \usepackage{sectsty}
    
    \let\LaTeXStandardTableOfContents\tableofcontents
    
    \renewcommand{\tableofcontents}{%
    \begingroup%
    \renewcommand{\bfseries}{\relax}%
    \LaTeXStandardTableOfContents%
    \endgroup%
    }%

    However, I want the actual title of the page that reads “Contents” to be bold like the rest of chapters.

    Is there a solution for this?
    Any thoughts would be appreciated.

  52. Yuliet

    Hi Tom,

    Something strange is happening with my code and is that the lof and lot show in the contents without me adding them and I just want to remove them. Do you know any way to do this? I am also trying to add one line to the content but it does not show where I add it, it shows after a whole chapter. It would be great if you could help me with this. Thanks in advance! Here is my code:

    \documentclass[12pt]{report} 
    \usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,bindingoffset=6mm]{geometry} 
    \usepackage{graphicx} 
    \include{Preamble}
    \begin{document}
    \tableofcontents
    \listoftables %this is showing in the table of contents and I want to remove it
    \listoffigures %this is showing in the table of contents and I want to remove it
    \newpage
    \addcontentsline{toc}{chapter}{\textcolor{black}{Chapter I}} %This is the line that only shows after all the content of ChapterOne and I am adding it before including Chapter 1. 
    \include{ChapterOne}
    • Hi Yuliet,

      I can’t really reproduce this. Try using the following package with the options to remove them from the table of contents.
      \usepackage{notlof,notlot]{tocbibind}

      Also, in my minimal example the added contents line appears before the chapter. Perhaps you are loading a package that interferes. Try creating a minimal example and add the packages one by one. If you need further help, please provide a minimal working example like the one below.

      \documentclass[12pt]{report}
      \usepackage{xcolor}
      \usepackage{graphicx}
      \usepackage[notlof,notlot]{tocbibind}
      
      \begin{document}
      \tableofcontents
      \newpage
      \addcontentsline{toc}{chapter}{\textcolor{black}{Chapter 0}}
      \chapter{Intro}
      \begin{figure}[ht]
      \centering
      \rule{2cm}{2cm}
      \caption[short for lof]{long figure caption}
      \label{fig:default}
      \end{figure}
      \end{document}

      Hope this helps.

      Best,
      Tom

Leave a Reply to NAJAR TarekCancel reply