1

I have the following MWE in which I have a bibliography (using biblatex) and an ununmbered chapter that I want to have them aligned, in the table of contents, not with the chapter numbers, but with the chapter titles.

I have already customized the alignment of the chapters, sections, subsections and subsubsections using the \dottedcontents command from titletoc, but have no idea how to make them work for the bibliography title and the unnumbered chapter. I tried using \dottedcontents{numberless-entry-format}[4pc]{}{4pc}{0.3pc} but with no luck.

The MWE:

\documentclass[a4paper, 12pt]{book}
\usepackage[utf8]{inputenc}

\usepackage{filecontents}

\begin{filecontents}{mwe.bib}
@misc{A01,
  author = {Author, A.},
  year = {2001},
  title = {Alpha},
}
\end{filecontents}

\usepackage[style=abnt, justify, extrayear]{biblatex}
\addbibresource{mwe.bib}

\usepackage[a4paper, top=3cm, bottom=2cm, left=3cm, right=2cm]{geometry}

\usepackage{titletoc}
\dottedcontents{chapter}[4pc]{}{4pc}{0.3pc}
\dottedcontents{section}[4pc]{}{4pc}{0.3pc}
\dottedcontents{subsection}[4pc]{}{4pc}{0.3pc}
\dottedcontents{subsubsection}[4pc]{}{4pc}{0.3pc}
\dottedcontents{numberless-entry-format}[4pc]{}{4pc}{0.3pc}
\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}

\title{MWE}
\author{Me}
\date{November 2021}

\begin{document}

\maketitle
\tableofcontents

\chapter{Introduction}

Just to cite the bibliography \cite{A01}.

\section{1st section}

\chapter{2nd chapter}
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}

\chapter*{No numbers!}
\addcontentsline{toc}{chapter}{No numbers!}


\printbibliography[
    heading=bibintoc, 
    title={My Bibliography}
    ]

\end{document}

The TOC in question: TOC without alignment

The idea is to have the "No..." and "My..." aligned with "Sub...", which is 4pc.

I'll gladly appreaciate any help, since I've been googling this all day long and I'm starting to open the same links as I did earlier today.

1
  • 2
    \titlecontents{chapter}[4pc]{}{\contentslabel{2.3em}}{}{\titlerule*[0.3pc]{.}\contentspage} instead of the simple dottedcontents should work. Nov 18, 2021 at 7:32

1 Answer 1

1

enter image description here

Inspired by the answer of Ulrike Fischer, you need to place the following in your preamble

\titlecontents{chapter}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}
\titlecontents{section}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}
\titlecontents{subsection}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}
\titlecontents{subsubsection}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}
\titlecontents{numberless-entry-format}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}

MWE

\documentclass[a4paper, 12pt]{book}
\usepackage[utf8]{inputenc}

\usepackage{filecontents}

\begin{filecontents}{mwe.bib}
    @misc{A01,
        author = {Author, A.},
        year = {2001},
        title = {Alpha},
    }
\end{filecontents}

\usepackage[style=abnt, justify, extrayear]{biblatex}
\addbibresource{mwe.bib}

\usepackage[a4paper, top=3cm, bottom=2cm, left=3cm, right=2cm]{geometry}

\usepackage{titletoc}
\titlecontents{chapter}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}
\titlecontents{section}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}
\titlecontents{subsection}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}
\titlecontents{subsubsection}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}
\titlecontents{numberless-entry-format}[4pc]{}{\contentslabel{4pc}}{}{\titlerule*[0.3pc]{.}\contentspage}

\setcounter{tocdepth}{3}
\setcounter{secnumdepth}{3}

\title{MWE}
\author{Me}
\date{November 2021}

\begin{document}
    
    \maketitle
    \tableofcontents
    
    \chapter{Introduction}
    
    Just to cite the bibliography \cite{A01}.
    
    \section{1st section}
    
    \chapter{2nd chapter}
    \section{Section}
    \subsection{Subsection}
    \subsubsection{Subsubsection}
    
    \chapter*{No numbers!}
    \addcontentsline{toc}{chapter}{No numbers!}
    
    
    \printbibliography[
    heading=bibintoc, 
    title={My Bibliography}
    ]
    
\end{document}
1
  • It worked perfectly! However, I was trying to understand those commands and I simply couldn't understand the titletoc manual. The [4pc] is the same as the dottedcontents. But I really couldn't understand the \titlerule*[0.3pc]{.}\contentspage. I take it that this command will work in the same way as the 0.3pc in my original MWE. I just don't understand all the "extra". Nov 18, 2021 at 14:06

You must log in to answer this question.

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