目录采用罗马数字自动换行

目录采用罗马数字自动换行

我正在尝试设置目录,其中章节用罗马数字列出。但是,当我到达第 VIII 章时,这与章节标题重叠。我可以通过在每个罗马数字前添加一个空格来解决这个问题,但我试图找出是否有更巧妙的方法来做到这一点,以便文本自动留空。

\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}

在此处输入图片描述

答案1

这是使用 的解决方案titletoc。您不应同时使用toclofttitletoc

\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} 

在此处输入图片描述

相关内容