7

I used titlesec for customizing chapter titles. How can I put the Table of contents title above the horizontal line?

(I am trying to customize the place of the title, not the title) Added figure is the result I get, from my existing code.

How can i take the Table of contents title above the line?

\usepackage{titlesec}
\titleformat{\chapter}[display]
{\bfseries\large}
{\filleft\MakeUppercase{\chaptertitlename} \large\thechapter}
{2ex}
{\titlerule
\vspace{2ex}%
\filleft}
\titlespacing*{\chapter}{0pt}{120pt}{6pt}
Sahika Koyun
  • 83
  • 1
  • 5
  • 1
    Does this answer your question: How to change the title of toc? – Paul Stanley Mar 04 '14 at 13:41
  • I tried this answer before, it doesn't work for me. I can change the title to "Table of Contents" from "Contents" but I cannot place it above the line as shown in the figure. – Sahika Koyun Mar 04 '14 at 14:03
  • @user47278 Yes, I've voted for re-opening the question. – Gonzalo Medina Mar 04 '14 at 14:07
  • Thank you, I have been looking for a solution for 2 days, I read documentation and checked questions. Still I cannot worked a solution for this problem. – Sahika Koyun Mar 04 '14 at 14:13
  • @SahikaKoyun I already have the answer, but cannot post it while the question is closed :( – Gonzalo Medina Mar 04 '14 at 14:15
  • @GonzaloMedina Is there any other way I can see your answer :( – Sahika Koyun Mar 04 '14 at 14:20
  • @SahikaKoyun In the meantime (while the question is reopened), here's the code you need: \titleformat{\chapter}[display] {\bfseries\large} {\filleft\MakeUppercase{\chaptertitlename} \large\thechapter} {2ex} {\titlerule\vspace{2ex}\filleft} \titleformat{name=\chapter,numberless}[display] {\bfseries\large} {\titlerule} {-7ex} {\filleft\MakeUppercase}[\vspace{5ex}] \titlespacing*{\chapter}{0pt}{120pt}{6pt} (sorry about the poor formatting, but comments don't allow nicer code formatting). – Gonzalo Medina Mar 04 '14 at 14:20

1 Answers1

6

With your current settings, The rule is placed above the chapter title and below the string "Chapter #", for numbered chapters. You need a different specification for unnumbered chapters (such as the ToC), to make the rule appear below the title; this can be achieved using another \titleformat command with the numberless key:

\documentclass{book}
\usepackage{titlesec}

\renewcommand\contentsname{Table of Contents}
\titleformat{\chapter}[display]
  {\bfseries\large}
  {\filleft\MakeUppercase{\chaptertitlename} \large\thechapter}
  {2ex}
  {\titlerule\vspace{2ex}\filleft}
\titleformat{name=\chapter,numberless}[display]
  {\bfseries\large}
  {\titlerule}
  {-7ex}
  {\filleft\MakeUppercase}[\vspace{5ex}]
\titlespacing*{\chapter}{0pt}{120pt}{6pt}

\begin{document}

\tableofcontents
\chapter{Test chapter}

\end{document}

An image of the ToC:

enter image description here

An image of a numbered chapter:

enter image description here

Gonzalo Medina
  • 505,128