1

I'm trying to format my report chapter titles to have a horizontal line under the chapter number but above the name of the chapter such that it reads

Chapter
'horizontal line'
Name of Chapter

I can do this using \titlesec straightforwardly enough, however it also adds the horizontal line to the table of contents, list of figures, etc. that I don't want. Is there an easy way to remedy this? I've tried various positions of the horizontal line in the \titleformat command but to no avail. Here's a MWE:

\documentclass[12pt]{report}

\usepackage{titlesec}

\titleformat{\chapter}[display]
{\centering\Large\scshape}
{\chaptername~\thechapter}
{-12pt}
{\rule{0.5\linewidth}{0.8pt}\\\Huge\bfseries}

\begin{document}
    
    
    \tableofcontents % I don't want the horizontal line above this
    
    \chapter{Example Title}
    
    Here is the text in the chapter.
    
\end{document}
2
  • 1
    Simply move the \titleformat macro invocation after the \tableofcontents. (It need not be in the preamble) Apr 19, 2022 at 3:00
  • Such an easy fix, thank you! Apr 19, 2022 at 3:10

2 Answers 2

1

Do you wanna table of content heading still centered as well. There is a way to use the \titleformat still in the preamble, and not influence the star version of the \chapter command.

\documentclass[12pt]{report}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\centering\Large\scshape}
{\chaptername~\thechapter\\[-10pt]\rule{0.5\linewidth}{0.8pt}}
{-2pt}
{\Huge\bfseries}

\begin{document}
    
\tableofcontents
    
\chapter{Example Title 1}
    Here is the text in the chapter.

\chapter*{Example Title 2}
    
\end{document}

enter image description here enter image description here enter image description here

1
  • I was planning on redefining the commands to centre the table of contents etc. but this solution removes that need - very useful, thank you! Apr 19, 2022 at 5:23
1

As commented, merely move the invocation of the\titleformat command after the \tableofcontents. That way, the format will not be changed until after the Table of Contents is typeset.

\documentclass[12pt]{report}

\usepackage{titlesec}


\begin{document}
    
    
    \tableofcontents % I don't want the horizontal line above this
    
\titleformat{\chapter}[display]
{\centering\Large\scshape}
{\chaptername~\thechapter}
{-12pt}
{\rule{0.5\linewidth}{0.8pt}\\\Huge\bfseries}

    \chapter{Example Title}
    
    Here is the text in the chapter.
    
\end{document}

enter image description here

enter image description here

You must log in to answer this question.

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