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

user41063
  • 1,967

1 Answers1

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

Bernard
  • 271,350
  • 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 I have to change with titlesec: \contentsname ? – user41063 Oct 30 '18 at 21:22
  • No, you have to use ``titleformat{withnumberless` 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
  • So is it impossible, for instance, to have Contents title on the right and Bibliography title on the left? – user41063 Oct 30 '18 at 22:06
  • And: \titleformat{name=\????? `Chapter? – user41063 Oct 30 '18 at 22:20
  • You can, because you may use \titleformat after begin{document}. Or you may in `titleformat, but it would be more complex. – Bernard Oct 30 '18 at 22:21
  • In the report class, yes, tableofcontents is a \chapter*. – Bernard Oct 30 '18 at 22:22
  • open a new tread: link – user41063 Oct 30 '18 at 22:45
  • How did you calcolated, in \titlecontents*{subsection} [3.525em] the length of 3.525 em? – user41063 Nov 04 '18 at 23:30
  • I did it by trial and error, checking with a very big zoom. – Bernard Nov 04 '18 at 23:40
  • thanx. however a similar escamotage is not suitable to solve my problem about biblliography title alignement... – user41063 Nov 05 '18 at 00:37
  • Do you mean for the bibliography title which appears in the title of contents? – Bernard Nov 05 '18 at 00:49
  • Yes, it protrudes on the left – user41063 Nov 05 '18 at 01:37
  • I added code and image in ADDENDUM NOVEMBER 4TH – user41063 Nov 05 '18 at 04:45
  • I tried with \phantom, but or doesn't work or doesn't compile – user41063 Nov 05 '18 at 14:42
  • 've updated the code. The trick was to add the spacing between label and title (0.5em) in the 4th mandatory argument of \titlecontents{chapter}, which was left empty, and is used for the formatting of unnumbered chapters. – Bernard Nov 05 '18 at 18:55
  • now it seems everywhere perfect. Thanx! – user41063 Nov 05 '18 at 21:09