2

I have a file as follows:

\documentclass[12pt]{article}
\begin{document}
\setcounter{tocdepth}{2}
\tableofcontents
\newpage
\section{A Section}
body

\begin{figure}
abc
\caption{a figure}
\end{figure}

\begin{table}{l}
efg
\caption{a table}
\end{table}

\newpage
\cleardoublepage
\listoffigures
\cleardoublepage
\listoftables
\end{document}

It compiles well. However, in the table of contents, List of Figures and List of Tables are not shown (please ignore the font and background colours).

enter image description here

Could anyone tell me how to let these 2 lists appear in the table of contents? Additionally, I would like to see 2 levels as follows: Lists on the first level, and all the lists on the second level, is it possible?

Lists                                               3
   List of Figures                                  3
   List of Tables                                   4
1
  • 1
    Add \addcontentsline{toc}{subsection}{List of figures} after \listoffigures. Is that what you want? You may also use \usepackage{tocbibind}.
    – user11232
    Jan 16, 2015 at 7:35

1 Answer 1

3

Something like this?

enter image description here

Code:

\documentclass[12pt]{article}
\begin{document}
\setcounter{tocdepth}{2}
\tableofcontents
\newpage
\section{A Section}
body

\begin{figure}
abc
\caption{a figure}
\end{figure}

\begin{table}{l}
efg
\caption{a table}
\end{table}

\newpage
\cleardoublepage
\addcontentsline{toc}{section}{Lists}
\addcontentsline{toc}{section}{\protect\numberline{}\listfigurename}
\listoffigures
\cleardoublepage
\addcontentsline{toc}{section}{\protect\numberline{}\listtablename}
\listoftables
\end{document} 

EDIT

If you want to add dashed lines only for those entries, load the tocloft package and issue

\renewcommand{\cftdot}{\_}

in the preamble and

\addtocontents{toc}{%
  \protect\renewcommand{\protect\cftsecleader}{\protect\cftdotfill{\protect\cftdotsep}}}

at the right point and then

\addtocontents{toc}{\protect\renewcommand{\protect\cftsecleader}{\protect\hfill}}

when they are not needed anymore, as in the following example

\documentclass[12pt]{article}
\usepackage{tocloft}
\renewcommand{\cftdot}{\_}

\begin{document}
\setcounter{tocdepth}{2}
\tableofcontents
\newpage
\section{A Section}
body

\begin{figure}
abc
\caption{a figure}
\end{figure}

\begin{table}{l}
efg
\caption{a table}
\end{table}

\newpage
\cleardoublepage
\addcontentsline{toc}{section}{Lists}
\addtocontents{toc}{%
  \protect\renewcommand{\protect\cftsecleader}{\protect\cftdotfill{\protect\cftdotsep}}}
\addcontentsline{toc}{section}{\protect\numberline{}\listfigurename}
\listoffigures
\cleardoublepage
\addcontentsline{toc}{section}{\protect\numberline{}\listtablename}
\listoftables
\cleardoublepage
\addtocontents{toc}{\protect\renewcommand{\protect\cftsecleader}{\protect\hfill}}
\section{Another section}
\end{document} 

Output

enter image description here

Otherwise, omit

\renewcommand{\cftdot}{\_}

and you will have dotted lines which, in my opinion, look better

enter image description here


EDIT #2

If you want that behavior for all entries, simply issue

\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}

in the preamble, depending on what you want.

This is an example with dotted lines

\documentclass[12pt]{article}
\usepackage{tocloft}
\renewcommand{\cftsecleader}{\cftdotfill{\cftdotsep}}

\begin{document}
\setcounter{tocdepth}{2}
\tableofcontents
\newpage
\section{A Section}
body

\begin{figure}
abc
\caption{a figure}
\end{figure}

\begin{table}{l}
efg
\caption{a table}
\end{table}

\newpage
\cleardoublepage
\addcontentsline{toc}{section}{Lists}
\addcontentsline{toc}{section}{\protect\numberline{}\listfigurename}
\listoffigures
\cleardoublepage
\addcontentsline{toc}{section}{\protect\numberline{}\listtablename}
\listoftables
\cleardoublepage
\section{Another section}
\end{document} 

Output

enter image description here

5
  • Thank you... Is it possible to added dash line between List of Figures and 3 (and List of Tables and 4)?
    – SoftTimur
    Jan 16, 2015 at 11:36
  • @SoftTimur Yes, see the edit. Jan 16, 2015 at 12:04
  • Sorry... what you put is full line, whereas I wanted dash/dotted line...
    – SoftTimur
    Jan 16, 2015 at 13:51
  • @SoftTimur There is a possibility with dotted lines in the answer. Dashed lines will look really ugly, in my opinion. Jan 16, 2015 at 15:34
  • @SoftTimur Anyway I've added a possibility with dashed lines, too... Jan 16, 2015 at 15:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .