7

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

3
  • 1
    What you have tried so far? Please add a minimal working example (MWE).
    – user11232
    Commented May 19, 2012 at 22:51
  • A few remarks: 1) Please embed your document as an image. I'm sure you'll understand people will be hesitant to download a pdf file of a total stranger. 2) You can check out what titlesec does in its documentation: texdoc.net/pkg/titlesec 3) I haven't done a loft of ToC modification, but I think tocloft is a popular package for that. I suggest you check that out, try to achieve your layout and if there's something specific you can't figure out, you're more than welcome to come back and ask about it.
    – doncherry
    Commented May 19, 2012 at 22:56
  • Should the format for the title apply to all chapters or just to the Table of Contents? Commented May 19, 2012 at 23:33

1 Answer 1

11

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

5
  • When I change the document class to report, it does not work. Any ideas? Thanks anyway, you have point me in a good direction :D
    – aljndrrr
    Commented May 19, 2012 at 23:46
  • @aljndrrr: I edited my answer to use report. Commented May 19, 2012 at 23:47
  • @aljndrrr in fact, I've just updated my answer again suggestiong you to use book instead of report and providing the corresponding code. Commented May 19, 2012 at 23:53
  • Thank you @gonzalo-medina this is what I was looking for
    – aljndrrr
    Commented May 20, 2012 at 0:15
  • when i do this, it automatically generates pages with each chapter but I have no idea how to edit them...
    – berinovski
    Commented Mar 29, 2023 at 13:17

You must log in to answer this question.

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