[Tex/LaTex] Numbering the List of Figures and Table of Contents

numberingtable of contents

I would like to number the list of figures and the table of contents, with Roman numerals, themselves (not the things listed in them).

Doing this, while leaving the main text in bold, and leaving the number unformatted.

I can't seem to find a way of doing so.

Best Answer

By default \tableofcontents and \listoffigures do not use numbered headings. This can be changed using the tocbibind package.

The following code redefines \tableofcontents and inserts the \tocchapter instruction, then loading the .toc file with \tocfile{\contentsname}{toc}.

The macro \unboldchapternumber defines the chapter number to be not bold and switches to \Roman and redefines the potential hyper anchor \theHchapter in case of hyperref being loaded.

  \renewcommand{\tableofcontents}{%
    \begingroup
    \unboldchapternumber%
    \tocchapter
    \tocfile{\contentsname}{toc}
    \endgroup
  }

After loading \listoffigures, the chapter counter should be reset to zero.

\documentclass{report}

\usepackage{tocbibind}
\usepackage{blindtext}
\usepackage{hyperref}

\makeatletter
\newif\ifhyperrefloaded
% Check whether hyperref is loaded
\@ifpackageloaded{hyperref}{
  \hyperrefloadedtrue
}{}
\makeatother


\newcommand{\unboldchapternumber}{%
  \renewcommand{\thechapter}{\normalfont\Roman{chapter}\bfseries}%
  \ifhyperrefloaded
  % Change the hyperanchors to prevent wrong anchors
  \renewcommand{\theHchapter}{tocchapter.\arabic{chapter}}%
  \fi
}

  \renewcommand{\tableofcontents}{%
    \begingroup
    \unboldchapternumber%
    \tocchapter
    \tocfile{\contentsname}{toc}
    \endgroup
  }
  \renewcommand{\listoffigures}{%
    \begingroup
    \unboldchapternumber
    \tocchapter
    \tocfile{\listfigurename}{lof}
    \endgroup
  }

\begin{document}
\tableofcontents
\listoffigures

\setcounter{chapter}{0}
\chapter{One}

\blindtext

\chapter{Two}

\blindtext
\end{document}