[Tex/LaTex] How to add horizontal line after references (biblatex) and glossary title

biblatexformattingglossariesrules

I need to have horizontal lines after each title.

For table of contents this works with:

\renewcommand{\cftaftertoctitle}{\vskip 3em \auftaktvz}

and

\newcommand{\auftaktvz}{{\vspace{-24pt}\rule{\textwidth}{0.5pt}\vspace{-30pt}}{\noindent}}

So it looks like:

Table of contents
----------------------------------------

1. ABC
2. EDF ...

For chapters this works with:

\chapter{My chapter title}\auftakt

and

\newcommand{\auftakt}{{\vspace{-24pt}\rule{\textwidth}{0.5pt}\vspace{40.5pt}}{\noindent}}

so it looks like

My chapter title
-------------------------------------------

My text goes here...

How can I change the formatting of the references and glossaries titles so that a horizontal line is also drawn there?

\usepackage[bibstyle=authoryear, autocite=footnote, citestyle=authoryear-icomp, autopunct=false, urldate=long, abbreviate=false, dateabbrev=false, backend=biber]{biblatex}
[...]
\usepackage[toc,xindy,nonumberlist,numberedsection=autolabel]{glossaries}

[...]

\printbibliography
[...]
\printglossary[title=\glossaryname,toctitle=\glossaryname] 

Currently these title heading are just printing like:

References

o Here comes list of authors...

and

Glossaries

List of Glossaries

How can I also get a horizontal line (rule) below the References and Glossaries titles?

Best Answer

In the documentation of the package titlesec you find how the normal chapter heading style can be defined and it's very easy to add a rule.

Adding \auftakt after all chapters is wrong, because it's error prone. If you want to modify the aspect of all chapter headings, you just need to act in one place. And this works for every chapter, even those added by \tableofcontents, \printbibliography or \printglossary.

\documentclass{book}

\usepackage{titlesec}
\usepackage[titles]{tocloft}
\usepackage{biblatex}

\addbibresource{xampl.bib}

\usepackage{lipsum}

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}
  {\chaptertitlename\ \thechapter}
  {20pt}
  {\Huge}
  [\vspace{1ex}\titlerule]
\titlespacing*{\chapter}{0pt}{50pt}{40pt}

\begin{document}
\frontmatter
\tableofcontents
\mainmatter
\chapter{My chapter title}

\section{A section title}

Here's a citation \cite{article-full}.
\lipsum

\printbibliography

\end{document}

Table of contents page

enter image description here

Chapter page

enter image description here

Bibliography

enter image description here