问题:在目录中,当章节和节号都是 2 位数字时,节号会粘贴在标题上。
(我在图表中遇到了同样的问题,但我认为这可能应该是一个不同的问题。)
其余一切都按预期呈现。
这里有一个匿名工作示例,其中包括文档其余部分所需的其他内容:
%Preamble
\documentclass[11pt,a4paper,french,oneside,openright]{book}
\usepackage[left=28mm,right=34mm,top=37mm,bottom=44mm]{geometry}
\usepackage{comment}
\begin{comment}
%\usepackage{biblatex}
%\addbibresource{Pages/bibliography.bib}
\end{comment}
\usepackage{float}
\usepackage{afterpage}
\usepackage{lastpage}
\newcommand{\blankpage}{
\null
\thispagestyle{empty}
% \addtocounter{page}{-1}
\newpage
}
\newcommand{\startcontentpagestyle}{
\pagestyle{fancy}
\lfoot{"Shortened title..."}
\rfoot{Page \thepage/\pageref{LastPage}}
\renewcommand{\headrulewidth}{0.1pt}
\renewcommand{\footrulewidth}{0.1pt}
\fancyhead{}
\lhead{\parbox[t]{0.5\textwidth}{\RaggedRight\rightmark\strut}}
\rhead{\parbox[t]{0.5\textwidth}{\RaggedLeft\leftmark\strut}}
\setlength{\headheight}{0\baselineskip}
\pagestyle{fancy}
\fancypagestyle{plain}{%
\fancyhf{}%
\fancyfoot[L]{"Shortened title..."}%
\fancyfoot[R]{Page \thepage/\pageref{LastPage}}%
\renewcommand{\headrulewidth}{0pt}% Line at the header invisible
\renewcommand{\footrulewidth}{0.1pt}% Line at the footer visible
}
}
\usepackage{fancyhdr}
\usepackage{ragged2e}
\usepackage{graphicx}
\graphicspath{ {./Images/} }
\usepackage{lipsum}
\usepackage{tocloft,calc}
%\renewcommand{\cftchappresnum}{Chapitre }
%\AtBeginDocument{\addtolength\cftchapnumwidth{\widthof{\bfseries Chapitre }}}
\title{Complete title}
\author{Author name}
\date{2021}
\usepackage{titlesec}
\usepackage[strings]{underscore}
% a command to tweak \addcontentsline for chapters
\newcommand{\chapitretocentry}{%
\let\oldacl=\addcontentsline % save original definition
\def\addcontentsline##1##2##3{% (re)define \addcontentsline
\def\tempa{##1}\def\tempb{toc}% store ##1 and toc in temp vars
\ifx\tempa\tempb % check if they are "equal"
\def\tempa{##2}\def\tempb{chapter}%
\ifx\tempa\tempb % check if ##2 is "equal" to chapter
\oldacl{##1}{##2}{\chaptername\space ##3}% apply original \addcontentsline adding \chaptername
% in the other cases, just apply the original \addcontentsline
\else
\oldacl{##1}{##2}{##3}%
\fi
\else
\oldacl{##1}{##2}{##3}%
\fi
}
}
\AtBeginDocument{\chapitretocentry} % invoke the command at the beginning
%Trying to get long titles in TOC
%Source: https://latex.org/forum/viewtopic.php?t=1267
\makeatletter
\newcommand*\std@chapter{}
\let\std@chapter=\@chapter
\renewcommand*\@chapter[2][]{\std@chapter[#2]{#2}\chaptermark{#1}}
\makeatother
\usepackage{datetime}
\usepackage[titletoc]{appendix}
\usepackage[french]{babel}
\usepackage{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan
}
\input{Config/Figure_commands.tex}
\begin{document}
\pagenumbering{gobble}
\tableofcontents
\newpage
\listoffigures
\listoftables
\newpage
\pagenumbering{arabic}
\setcounter{chapter}{0}
\setcounter{page}{16}
\part{Introduction}
\startcontentpagestyle
\chapter{Chapter 1}
\chapter{Chapter 2}
\chapter{Chapter 3}
\chapter{Chapter 4}
\chapter{Chapter 5}
\chapter{Chapter 6}
\chapter{Chapter 7}
\chapter{Chapter 8}
\chapter{Chapter 9}
\chapter{Chapter 10}
\section{Chapter 10 - Section 1}
\section{Chapter 10 - Section 2}
\section{Chapter 10 - Section 3}
\section{Chapter 10 - Section 4}
\section{Chapter 10 - Section 5}
\section{Chapter 10 - Section 6}
\section{Chapter 10 - Section 7}
\section{Chapter 10 - Section 8}
\section{Chapter 10 - Section 9}
\section{Chapter 10 - Section 10}
\chapter{Chapter 11}
\section{Chapter 11 - Section 1}
\section{Chapter 11 - Section 2}
\section{Chapter 11 - Section 3}
\section{Chapter 11 - Section 4}
\section{Chapter 11 - Section 5}
\section{Chapter 11 - Section 6}
\section{Chapter 11 - Section 7}
\section{Chapter 11 - Section 8}
\section{Chapter 11 - Section 9}
\section{Chapter 11 - Section 10}
\end{document}
这个问题被关闭了,并指向目录中的罗马数字变得“太宽” 但是当我尝试包含 \usepackage[tocindentauto]{tocstyle} 时,文档没有任何变化,所有日志都消失了(空白日志),所以我不知道文档是否已经编译。尝试了其他一些建议,但没有得到任何结果。请重新打开。
答案1
您使用文档类 {book},而如上述链接中所述,{tocstyle} 最适合 KOMA。对于您来说,您应该查看同一链接下的另一个答案,该答案告诉您至少包含
\usepackage[titles]{tocloft}
\renewcommand*\cftsecnumwidth{3em}% and may be also
\renewcommand*\cftchapnumwidth{2em}%
到你的序言中。(你可以插入任何你觉得合适的尺寸(宽度)。)