I have been trying to get a simple thing working with titlesec
: getting a horizontal line under each chapter. There are many tutorials, documents and questions on TeX that explain how this can be done. But … each one of those answers have given me absolutely nothing. These are the solutions I have tried:
- Add a rule after chapter title using titlesec
- Two horizontal lines above and under chapter-entry
- Title between lines
But in each case, the compiled pdf shows exactly what it was showing without any use of \titleformat
. My current preamble uses titlesec
as follows:
\documentclass[11pt,oneside]{book}
\usepackage{titlesec}
% Below "\section" can be replaced with "\subsection" and "\subsubsection"
% in order to customize the corresponding headings. "bch" - Bitstream
% Charter, "b" - bold.
\titleformat{\section}[hang]
{\usefont{T1}{bch}{b}{n}\selectfont}
{} % label
{0em} % horizontal separation between label and title body
{\hspace{-0.4pt}\Large \thesection\hspace{0.6em}} % before-code
[] % after-code
\titleformat
{\chapter} % command
[display] % shape
{\normalfont\huge\bfseries} % format
{\chaptertitlename\ \thechapter} % label
{20pt} % sep
{\Huge}[\vspace{2ex}\titlerule] % before-code
This is just one of at least a dozen variations I have tried (including the example at the end of the titlesec documentation, including the {name=\chapter,numberless}
method explained in section 3.8, but all I have to show for it is this screenshot:
As you can see, there is no horizontal line anywhere over, under or near the chapter "Abstract". The document is nearly empty right now. After the preamble ends, all I have is
\begin{document}
\maketitle
\chapter*{Abstract}
Lorem Ipsum etc. etc.
\end{document}
I hope I was able to provide an MWE. Please let me know what I am doing wrong here so that even the most basic example is producing no result.
Best Answer
You have defined the format for numbered chapters and using an un-numbered chapter for
Abstract
. Defining the format for un-numbered chapters too is needed in this case to get a rule.I have not adjusted the spacing. Please do so using
\titlespacing*
The default isPlease do it also for un-numbered chapters using