1

Referring to this tread Section titles alignement with titletoc I've a further and (I hope) last question. I've a problem to apply this code to subsection to obtain this result: enter image description here My (wrong) code it's only a rough and wrong attempt to change the fine code already suggested to me:

\documentclass[a4paper]{report}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\setmainfont[Ligatures=TeX,Numbers=OldStyle]{EB Garamond}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%% TABLE OF CONTENTS SETTINGS
\usepackage{titletoc}

% book -- titletoc patch for \part:
% https://tex.stackexchange.com/a/454553/134574
\usepackage{etoolbox}
\makeatletter
\patchcmd\@part
  {\thepart}
  {\protect\numberline{\thepart}}
  {}{\FAIL}
\makeatother

\makeatletter
\contentsmargin[-1.55em]{1.55em}

\titlecontents{chapter}
  [0em]
  {\vspace*{\baselineskip}}
  {\mdseries
   \llap{\hb@xt@\@pnumwidth{\hfil}\quad}\thecontentslabel
   \vspace*{0.1\baselineskip}%
   \upshape
  }
  {\mdseries
   \llap{\hb@xt@\@pnumwidth{\hfil\thecontentspage}\quad}
  }
  {}
  []

\titlecontents{section}
  [0em]
  {\vspace*{\baselineskip}}
  {\mdseries
   \llap{\hb@xt@\@pnumwidth{\hfil\thecontentspage}\quad}\thecontentslabel}
  {\mdseries
   \llap{\hb@xt@\@pnumwidth{\hfil\thecontentspage}\quad}
  }
  {}
  []

\titlecontents*{subsection}
  [0em]
  {}
  {\footnotesize}
  {}
  {\footnotesize,~\thecontentspage}
  [~--~]
  []

\makeatletter\@addtoreset{chapter}{part}\makeatother
% make chapter begin from 1 every part

\renewcommand{\thechapter}{\scshape\roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

\renewcommand*\contentsname{\hfill\mdseries\huge Contents}
% put ToC title in the right side of the page

\tableofcontents

\chapter{A Very Short History of Rethorics}
\section{The Greek World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}

\chapter{A Very Short History of Rethorics}
\section{The Greek World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}

\end{document}

I was not able to product the correct alignement of chapter and section numbers.

At last, I don't understand why

\renewcommand*\contentsname{\hfill\mdseries\huge Contents}

works only if I put in after \begin{document}, and not into the preamble

thanx!

ADDEDNDUM NOVEMBER 4TH

I've a further, little problem with numberless chapters. Consider the following code:

\begin{filecontents*}{\jobname.bib}
@book{ bottero:1992,
  author       = "Vickers, Brian.",
  title        = "In Defence of Rhetorics",
  publisher    = "Clarendon Press",
  location     = "Oxford",
  year         = "1989",
}
\end{filecontents*}

\documentclass[a4paper]{report}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\setmainfont[Ligatures=TeX,Numbers=OldStyle]{EB Garamond}

\usepackage{titletoc}

\titlecontents{chapter}
[3em]
{\vspace*{\baselineskip}\mdseries}
{\contentslabel[\hfill\thecontentslabel\phantom{.}]{3em}\enspace}
{}
{\hfill\llap{\makebox[\dimexpr\linewidth-1.3pc][l]{\thecontentspage}}}
[]

\titlecontents{section}
  [3em]
  {\vspace*{\baselineskip}\mdseries}
  {\contentslabel[\hfill\thecontentslabel]{3em}\enspace}
  {}
{\hfill\llap{\makebox[\dimexpr\linewidth-1.3pc][l]{\thecontentspage}}}
  []

\titlecontents*{subsection}
  [3.525em]
  {\footnotesize}
  {}
  {}
  {,~\thecontentspage}
  [~--~]
  []

\makeatletter\@addtoreset{chapter}{part}\makeatother
% make chapter begin from 1 every part

\renewcommand{\thechapter}{\scshape\roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}

\usepackage[backend=biber,style=philosophy-verbose,scauthors=all,%
lowscauthors=true,giveninits,classical=true,volnumformat=strings,%
volumeformat=romansc,sorting=nyt,commacit=true,citepages=omit,%
editionformat=superscript,indexing]{biblatex}

\usepackage{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}

\begin{document}
\renewcommand{\thesection}{\arabic{section}.}
\renewcommand*\contentsname{\hfill\mdseries\huge Contents\hspace*{1.2em}}

\tableofcontents

\chapter{A Very Short History of Rhetoric}
\section{The Greek World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}

\chapter{A Very Short History of Rhetoric}
\section{The Greek World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}

\addcontentsline{toc}{chapter}{\bibname}
\printbibliography

\end{document}

You'll realize that the chapter title Bibliography protrudes respect the other titles, as in the attached pic:

enter image description here

How is it possible to aligne it correctly? Thanx

1

Is this what you want?

\begin{filecontents*}{\jobname.bib}
@book{ bottero:1992,
  author = "Vickers, Brian.",
  title = "In Defence of Rhetorics",
  publisher = "Clarendon Press",
  location = "Oxford",
  year = "1989",
}
\end{filecontents*}

\documentclass[a4paper]{report}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\setmainfont[Ligatures=TeX,Numbers=OldStyle]{EB Garamond}

\usepackage{titletoc}

\titlecontents{chapter}
[3em]
{\vspace*{\baselineskip}\mdseries}
{\contentslabel[\hfill\thecontentslabel\phantom{.}]{3em}\enspace}
{\hspace*{0.5em}}
{\hfill\llap{\makebox[\dimexpr\linewidth-1.3pc][l]{\thecontentspage}}}
[]

\titlecontents{section}
  [3em]
  {\vspace*{\baselineskip}\mdseries}
  {\contentslabel[\hfill\thecontentslabel]{3em}\enspace}
  {}
{\hfill\llap{\makebox[\dimexpr\linewidth-1.3pc][l]{\thecontentspage}}}
  []

\titlecontents*{subsection}
  [3.525em]
  {\footnotesize}
  {}
  {}
  {,~\thecontentspage}
  [~--~]
  []

\makeatletter\@addtoreset{chapter}{part}\makeatother
% make chapter begin from 1 every part

\renewcommand{\thechapter}{\scshape\roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}

\usepackage[backend=biber,style=philosophy-verbose,scauthors=all,%
lowscauthors=true,giveninits,classical=true,volnumformat=strings,%
volumeformat=romansc,sorting=nyt,commacit=true,citepages=omit,%
editionformat=superscript,indexing]{biblatex}

\usepackage{filecontents}
\addbibresource{\jobname.bib}
\nocite{*}

\begin{document}

\renewcommand{\thesection}{\arabic{section}.}
\renewcommand*\contentsname{\hfill\mdseries\huge Contents\hspace*{1.2em}}

\tableofcontents

\chapter{A Very Short History of Rhetoric}
\section{The Greek World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}

\chapter{A Very Short History of Rhetoric}
\section{The Greek World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}
\subsection{Aristoteles}
\subsection{The hellenistic Age}
\subsection{The Latin World}

\addcontentsline{toc}{chapter}{\bibname}
\printbibliography

\end{document}

enter image description here

  • Yes, it seems perfect! Some troubles in combining titlesec, titletoc and \marginpar, but I've to experiment more and better. In the meantine: thanx!! – user41063 Oct 30 '18 at 20:13
  • all working fine now. Only, plz consider: I don't understand why \renewcommand*\contentsname{\hfill\mdseries\huge Contents} works only if I put in after \begin{document}, and not into the preamble – user41063 Oct 30 '18 at 20:35
  • You can write in the preamble \AtBeginDocument{...}. I suspect the problem comes from polyglossia, which redefines \contentsname,depending on the language, and does so at the beginning of the document. Anyway, what you did is bad practice: contentsname is not contents title formatting. You should define its formatting with titlesec, since you load its companion package titletoc. – Bernard Oct 30 '18 at 21:05
  • Is the <command> I have to change with titlesec: \contentsname ? – user41063 Oct 30 '18 at 21:22
  • No, you have to use ``titleformat{` with numberless key. It will reformat all unnumbered chapters, i.e. also the bibliography title, index title, &c.: they'll all be flushright. – Bernard Oct 30 '18 at 21:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.