[Tex/LaTex] How to change locally titletoc

table of contentstitletoc

Please, consider this code

\begin{filecontents*}{\jobname.bib}
@book{ hoyningen:1993,
  author         = "Hoyningen-Huene, Paul",
  title          = "Recontructing Scientific Revolutions",
  publisher      = "The University of Chicago Press",
  location       = "Chicago",
  year           = "1993",
}
\end{filecontents*}

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{titlesec}
\usepackage[dotinlabels]{titletoc}
\contentsmargin{0pt}
\titlecontents{chapter}[4pc]{\addvspace{1pc}}
{\contentsmargin {0 pt}\makebox[0pt][r]{\quad\makebox[30pt][r]{\textsc{\romannumeral
\thecontentslabel\quad}}}}
{}
{}
{}

\contentsmargin{0pt}
\titlecontents{section}[4pc]
{\contentsmargin {0 pt}\makebox[0pt][r]{\thecontentspage\quad\makebox[30pt][r]{\textsc{\thecontentslabel.\quad}}}}
{}
{}
{}

\contentsmargin{0pt}
\titlecontents{subsection}[4pc]
{\contentsmargin {0 pt}\makebox[0pt][r]{\thecontentspage\quad\makebox[30pt][r]{\textsc{\thecontentslabel.\quad}}}}
{}
{}
{}

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

\usepackage[style=philosophy-verbose,backend=biber]{biblatex}
\addbibresource{\jobname.bib}
\nocite{*}

\begin{document}

\tableofcontents

\chapter{Chapter One}
\section{Section one}
\section{Section two}

\chapter{Chapter Two}
\section{Section one}
\section{Section two}
\section{Section three}

\chapter{Chapter Three}
\section{Section one}
\section{Section two}

\chapter*{\bibname}
\addcontentsline{toc}{chapter}{\bibname}

\end{document}

In spite of my code, I'd like to have in any case the page number in the Table of contents for Bibliography. Is there a way to change locally the setting for that voice? Thanx!

=======================================================================

ADDENDUM
Almost perfect. I don't understand why, but I obtain
enter image description here
where the page number of Bibliography is a little too on the right… In my case I've to set {\llap{\makebox[\dimexpr30pt +1.75em\relax][l]{\thecontentspage}}}, but only by trials and errors…

Best Answer

This solution works independently of the page number of the bibliography...

  1. Remember to use

    \printbibliography[heading=bibintoc]
    

    instead of

    \chapter*{\bibname}
    \addcontentsline{toc}{chapter}{\bibname}
    

    to have your bibliography printed and in the ToC.

  2. Define the numberless-entry-format for \chapter in the same way you've defined it for the other sectioning commands:

    \titlecontents{chapter}[4pc]
    {\addvspace{1pc}}
    {\makebox[0pt][r]{\makebox[30pt][r]{\textsc{\romannumeral\thecontentslabel\quad}}}}
    {\makebox[0pt][r]{\thecontentspage\quad\makebox[30pt][r]{}}}
    {}
    

MWE:

\begin{filecontents*}{\jobname.bib}
@book{ hoyningen:1993,
  author         = "Hoyningen-Huene, Paul",
  title          = "Recontructing Scientific Revolutions",
  publisher      = "The University of Chicago Press",
  location       = "Chicago",
  year           = "1993",
}
\end{filecontents*}

\documentclass[a4paper]{report}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{titlesec}
\usepackage[dotinlabels]{titletoc}


\contentsmargin{0pt}

\titlecontents{chapter}[4pc]
{\addvspace{1pc}}
{\makebox[0pt][r]{\makebox[30pt][r]{\textsc{\romannumeral\thecontentslabel\quad}}}}
{\makebox[0pt][r]{\thecontentspage\quad\makebox[30pt][r]{}}}
{}

\titlecontents{section}[4pc]
{}
{\makebox[0pt][r]{\thecontentspage\quad\makebox[30pt][r]{\textsc{\thecontentslabel.\quad}}}}
{}
{}

\titlecontents{subsection}[4pc]
{}
{\makebox[0pt][r]{\thecontentspage\quad\makebox[30pt][r]{\textsc{\thecontentslabel.\quad}}}}
{}
{}

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

\usepackage[style=philosophy-verbose,backend=biber]{biblatex}
\addbibresource{\jobname.bib}
\nocite{*}

\begin{document}

\tableofcontents

\chapter{Chapter One}
\section{Section one}

\chapter{Chapter Two}
\section{Section one}

\chapter{Chapter Three}
\section{Section one}

\chapter{Chapter Four}
\section{Section one}

\chapter{Chapter Five}
\section{Section one}

\chapter{Chapter Six}
\section{Section one}

\chapter{Chapter Seven}
\section{Section one}

\chapter{Chapter Eight}
\section{Section one}

\chapter{Chapter Nine}
\section{Section one}

\printbibliography[heading=bibintoc]

\end{document}

Output:

enter image description here

Some remarks:

  1. If you set

    \contentsmargin{0pt}
    

    once and don't want to change it, you don't need to repeat it.

  2. You are using the second mandatory argument of \titlecontents as it was the third...

    In other words, you should write

    \titlecontents{section}[4pc]
    {}
    {\makebox[0pt][r]{\thecontentspage\quad\makebox[30pt][r]{\textsc{\thecontentslabel.\quad}}}}
    {}
    {}
    

    instead of

    \titlecontents{section}[4pc]
    {\contentsmargin {0 pt}\makebox[0pt][r]{\thecontentspage\quad\makebox[30pt][r]{\textsc{\thecontentslabel.\quad}}}}
    {}
    {}
    {}
    
Related Question