[Tex/LaTex] Custom table of contents layout

table of contents

I am trying to achieve the following layout of the table of contents

enter image description here

But I'm a little lost on how to use the titlesec package, because I do not know if this package is really for editing the table of contents or just for the titles…

I appreciate your help

Current advances:

\documentclass[letterpaper,12pt,oneside,onecolumn,final,openany]{report}
\usepackage[left=2.7cm,top=2.5cm,right=2.2cm,nohead,nofoot]{geometry}
\usepackage{titlesec}
\usepackage{tocloft}

\renewcommand{\cftaftertoctitle}{\hrulefill}

\begin{document}
\pagenumbering{roman}
\tableofcontents
\clearpage
\listoffigures
\clearpage
\listoftables
\clearpage
\pagenumbering{arabic}

\chapter{Introduction}
\label{chap:intro}
Lorem 

\section{Lorem ipsum}
\label{sec:intro:lorem}

Pellentesque

\subsection{Ipsum}
\label{sec:intro:ipsum}

Etiam 

Result:

Result

Best Answer

Here's one possible option: the titlesec package was used to format the title for unnumbered sections; the tocloft package was used to format the section entries in the ToC (only change was to typeset chapter entries in \normalfont):

\documentclass{report}
\usepackage{titlesec}
\usepackage[titles]{tocloft}

\renewcommand\cftchapfont{\normalfont}
\renewcommand\cftchappagefont{\normalfont}

\AtBeginDocument{\renewcommand\contentsname{Table of Contents}}

\titleformat{\chapter}[display]
{}{\hfill\rule{.7\textwidth}{3pt}}{0pt}
{\hspace*{.3\textwidth}\huge\bfseries}[\addvspace{-1pt}]
\titleformat{name=\chapter,numberless}[display]
{}{\hfill\rule{.7\textwidth}{3pt}}{0pt}
{\hspace*{.3\textwidth}\huge\bfseries}[\addvspace{-1pt}]

\begin{document}

\tableofcontents
\clearpage

\chapter{Test Chapter}
\section{Test Subsection}

\end{document}

enter image description here

Since the OP didn't provide any information regarding the formatting for titles of numbered chapters, my example code included a provisional definition in this case.

As a side note, I used that you need roman numbering for the frontmatter part of your document and then arabic numbering in the mainmatter part: this suggests that switching to the book document class might be a sensible choice, since now you can use \frontmatter, \mainmatter, and \backmatter which will give you some automatic formatting for page numbering (amongst other things); I also used the tocbibind package to easily include into the ToC entries for the LoF and LoT :

\documentclass{book}
\usepackage[nottoc]{tocbibind}
\usepackage{titlesec}
\usepackage[titles]{tocloft}

\renewcommand\cftchapfont{\normalfont}
\renewcommand\cftchappagefont{\normalfont}

\AtBeginDocument{\renewcommand\contentsname{Table of Contents}}

\titleformat{\chapter}[display]
{}{\hfill\rule{.7\textwidth}{3pt}}{0pt}
{\hspace*{.3\textwidth}\huge\bfseries}[\addvspace{-1pt}]
\titleformat{name=\chapter,numberless}[display]
{}{\hfill\rule{.7\textwidth}{3pt}}{0pt}
{\hspace*{.3\textwidth}\huge\bfseries}[\addvspace{-1pt}]

\begin{document}

\frontmatter
\tableofcontents
\listoftables
\listoffigures

\mainmatter
\chapter{Test Chapter}
\section{Test Subsection}

\end{document}

enter image description here

Related Question