Skip to content

Latex: list of table, list of figures, and bibliography in ToC

May 15, 2009

While generating Table of Contents (ToC) and bookmarks for hyperref package, latex uses the anchors created while generating the document. However, the problem is that list of figures, list of tables, and bibliography created autometically by latex do not have any anchors. Therefore, it is not possible normally to have them in the ToC. However, sometimes it is required that they be in the ToC as well as in the bookmarks list. One way to make them appear in the ToC is to put a manual entry in the source file, such as:

\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures

However, more often than not (especially when the list is more than one page) this creates wrong page numbering in the ToC. This is because there is actually no hard anchor in the beginning of the list of figures. So, latex uses the last defined anchor which may not be the original beginning of the list.

To resolve this situation, we need to put an anchor at the beginning of the list. One way to do that is to put a phantomsection before it.

\phantomsection \label{listoffig}
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures

However, the problem with this is that, if the previous page before the list is not full, then the anchor is created at the middle of the previous page and the page numbering is again wrong. This observation brings a new solution which works perfectly:

\newpage
\phantomsection \label{listoffig}
\addcontentsline{toc}{chapter}{List of Figures}
\listoffigures

So, create a newpage first, this ensures you are in a completely new page. And then create an anchor using phantomsection. Then add the contentsline which generates correct link to the list. :)

About these ads
20 Comments leave one →
  1. Lorenzo permalink
    June 29, 2009 3:02 pm

    Hi

    I think you should mention that \phantomsection is included in the hyperref package and therefore it needs t be included at the beginning of the document

    cheers for the help anyway, it was really usefull :) !!

    • sumanta679 permalink*
      July 2, 2009 10:14 am

      Thanks Lorenzo! I guess your comment already done the job of mentioning :) Hope the post helped.

      //sumanta

  2. Alfinmass permalink
    December 11, 2009 4:10 am

    I think that if you use \cleardoublepage before the \addcontentsline works too and it will make sure the list of figures starts in a new page, odd if using twoside. Anyone knows how to determine if a figure exists before calling the \addcontentsline?

    • January 26, 2010 9:56 am

      Thanks! That really helped. The hyperref package was creating problems for me.

    • Rania permalink
      November 9, 2010 2:43 am

      Thanks. Your solution worked perfect for me, but the one that uses \phantomsection doesn’t work for some reason

      This works!
      \cleardoublepage
      \addcontentsline{toc}{chapter}{\listfigurename}
      \listoffigures

      Thanks soooooooo much :)

      • Rania permalink
        November 9, 2010 2:45 am

        Note that I defined \listoffigures as List of Figures….Just for others to know.

  3. Aous permalink
    February 16, 2010 4:33 pm

    Your insights are really helpful. Thank you. I have one question: Do you really need the “\phantomsection \label{listoffig}”?

    Anyway, if you are only interested in making them bookmarks for hyperref package, it is sufficient to use
    \newpage
    \currentpdfbookmark{List of Figures}{bm:listoffigures}
    \listoffigures

    Hope this is useful. Waiting for your comments :)

    • sumanta679 permalink*
      February 16, 2010 4:41 pm

      thanks! I really didn’t know about currentpdfbookmark tag. phantomsection was required to make an anchor at that position so that its possible to jump to exact that position from table of contents. Otherwise, the jump was going to wrong place.

  4. Alex permalink
    April 14, 2010 7:05 pm

    Almost. This works for putting in a link to the lof in the toc, but it also prevents the minitoc from printing at the beginning of each chapter. Any ideas on how to get around this?

    • sumanta679 permalink*
      April 15, 2010 12:28 am

      errrrr, not really….haven’t been in touch with latex since finishing my thesis. Hopefully you would find a solution pretty soon…and share it here.

  5. Pavel permalink
    October 6, 2010 4:07 pm

    Hi, my question is the opposite, how to exclude LoF and LoT refs from ToC? I tried \usepackage[notlot,notlof]{tocbibind}, but faced a ton of compilation errors due to bibliography, so I gave up. Is there a quick and easy way to doing this?

    Thanks

    • sumanta679 permalink*
      October 7, 2010 1:34 pm

      Hi,

      Thanks for the comment. I am away from writing anything using latex for quite a long time now and so am somewhat out of touch with it. Sorry I couldn’t help you out of my head to solve the problem but please come back and post a solution if you can figure it out.

  6. Anonymous permalink
    November 19, 2010 9:17 am

    Hi, I got a problem,in List of figures, lines are overlapping one another and become a block of mess. Can anyone help me in how to make this work?

  7. August 7, 2011 4:21 am

    Dears,

    I have something worried, when i used \listoffigures , it continues for many paper after the figures ended ? any idea ?

  8. Andrea permalink
    September 5, 2011 12:14 pm

    Hi,
    I would like to start the count of citations from Chapter 1 of my Thesis.
    Up to now, it starts counting from List of Figures and List of Tables.

    Can anyone comment on this?
    Thank you

  9. January 12, 2012 2:49 pm

    My solution was:

    \usepackage{hyperref}

    \tableofcontents %generale

    \cleardoublepage
    \phantomsection
    \addcontentsline{toc}{chapter}{List of Figures}
    \listoffigures

  10. Anonymous permalink
    December 19, 2012 1:05 am

    Thanks a lot, really helped! End of master thesis in sight ;)

  11. Rumen permalink
    February 2, 2013 7:56 pm

    Great! Thank you very much!

  12. Anonymous permalink
    March 8, 2014 2:28 am

    Cheers mate, that helped !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: