6

I am trying to set up a TOC where chapters are enumerated with roman numerals. However, when I get to VIII, say, this overlaps with the chapter title. I can fix this by adding a space before every roman numeral in the TOC, but I was trying to figure out if there is a fancier way to do this, so that text auto-spaces.

\documentclass[a4paper,14pt]{book}
\usepackage{tocloft}
\usepackage{titletoc}
\titlecontents*{subsection}% <section>
  [1.55 cm]% <left>
  {\small}% <above-code>
  {\thecontentslabel. \hspace{3pt}}% <numbered-entry-format>; you could also use {\thecontentslabel. } to show the numbers
  {}% <numberless-entry-format>
  {}% <filler-page-format>
  [ --- \ ]% <separator>
  []% <end>
\setcounter{tocdepth}{2}% Display up to \subsection in ToC

\addtolength{\cftchapnumwidth}{10 pt}

%\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftchapaftersnum}{.}
%\renewcommand{\cftsubsecaftersnum}{.}

\renewcommand\cftsecfont{\normalfont}
\renewcommand\cftsecpagefont{\normalfont}
\renewcommand{\cftsecleader}{\cftdotfill{\cftsecdotsep}}
\renewcommand\cftsecdotsep{\cftdot}
\renewcommand\cftsubsecdotsep{\cftdot}

\renewcommand{\thechapter}{\Roman{chapter}} 
\renewcommand{\thesection}{\arabic{section}} 
\renewcommand{\thesubsection}{\Roman{subsection}}

\makeindex

\begin{document}

 \tableofcontents

\chapter{Chapter}
\chapter{Chapter}
\chapter{Chapter}
\chapter{Chapter}
\chapter{Chapter}
\chapter{Chapter}
\chapter{Chapter}
\chapter{Chapter}

\end{document}

enter image description here

1 Answer 1

8

Here is a solution with titletoc. You shouldn't use both tocloft and titletoc.

\documentclass[a4paper]{book}
\usepackage[14pt]{extsizes}
\usepackage[utf8]{inputenc}
\usepackage[showframe]{geometry}
\usepackage[rightlabels]{titletoc}
\contentsmargin{1.5em}
\titlecontents{chapter}
[2em] %
{\bigskip}
{\contentslabel[\thecontentslabel.]{2em}\hspace{0.333em}}%\thecontentslabel
{\hspace*{-2em}}
{\hfill\contentspage}[\smallskip]%\hfill

\titlecontents{section}% <section>
[2.35em]% <left>
{\small\contentsmargin{1.5em}}% <above-code>
{\thecontentslabel.\hspace{3pt}}% <numbered-entry-format>; you could also use {\thecontentslabel. } to show the numbers
{}% <numberless-entry-format>
{\enspace\titlerule*[0.5pc]{.}~\contentspage}% <filler-page-format>

\titlecontents*{subsection}% <section>
[3.23em]% <left>
{\footnotesize\contentsmargin{0em}}% <above-code>
{\thecontentslabel. \hspace{3pt}}% <numbered-entry-format>; you could also use {\thecontentslabel. } to show the numbers
{}% <numberless-entry-format>
{}% <filler-page-format>
[ --- \ ]% <separator>
[]% <end>
\setcounter{tocdepth}{2}% Display up to \subsection in ToC

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\Roman{subsection}}

\makeindex

\begin{document}

\tableofcontents

\chapter{Chapter the First}
\section{A section}
\section{Another section}
\section{A last section with subsections}
\subsection{A nice subsection}
\subsection{An enthralling subsection}
\subsection{The subsection you’ve always dreamt of}
\chapter{Chapter the Second}
\chapter{Chapter the Third}
\chapter{Chapter the Fourth}
\chapter{Chapter the Fifth}
\chapter{Chapter the Sixth}
\setcounter{page}{200}
\chapter{Chapter the Seventh}
\section{Yet another section}
\chapter{Epilogue}

\end{document} 

enter image description here

10
  • +1 This style is much easier to do with titletoc than with tocloft. I've deleted my answer.
    – Alan Munn
    Jul 17, 2017 at 2:02
  • 1
    @AlanMunn: Thanks for having edited. I'm afraid my typo was of the Freudian kind (toclost:o)).
    – Bernard
    Jul 17, 2017 at 2:07
  • :D Indeed.....!
    – Alan Munn
    Jul 17, 2017 at 2:08
  • OK, so I should replace all the lines of my MWE (which are part of a much larger file) with your lines, correct? Your subsection numbering seems to be continuing the section number, perhaps that is unintended.
    – Pedro
    Jul 17, 2017 at 4:31
  • Question: two digit page numbers are right aligning correctly, but when I get to three digit page numbers, they appear outside the margin you set. Is this normal?
    – Pedro
    Jul 17, 2017 at 4:39

You must log in to answer this question.

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