我想在目录中的章节中添加虚线。目前我的 PDF 和代码如下所示:
\documentclass[12pt,a4paper,twoside]{report} %openright
%Schriftart Arial - ACHTUNG: Compile with XeLaTeX (not PDFLaTeX)!
\usepackage{fontspec}
\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{Arial}[Scale = 1.0]
%Seitenlayout
\usepackage[top=2.5cm, bottom=2cm, left=2.5cm, right=2.5cm,paper=a4paper]{geometry}
%Zeilenabstand ändern
\usepackage[onehalfspacing]{setspace}
%Graphiken und Bilder
\usepackage{subfig}
%Kopfzeile
\usepackage{fancyhdr}
%Verzeichnisse
\usepackage[notindex, nottoc, numbib]{tocbibind}
%\usepackage[subfigure]{tocloft}
%\renewcommand\cftchapdotsep{\cftdotsep}
%Längenangaben für den Abstand zwischen zwei Absätzen.
\usepackage{parskip}
%Kapitelanzeige und -platzierung im Text
\usepackage[clearempty]{titlesec}
\titleformat{\chapter}{\normalfont\fontsize{16pt}{0}\bfseries}{\thechapter.}{9pt}{}
\titleformat{\section}{\normalfont\fontsize{14pt}{0}\bfseries}{\thesection}{9pt}{}
\titleformat{\subsection}{\normalfont\fontsize{12pt}{0}\bfseries}{\thesubsection}{9pt}{}
\titlespacing*{\chapter}{0pt}{-22pt}{7pt}
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Formatierung der Kopfzeile
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\setlength{\headheight}{0.6cm}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL,OR]{\fontsize{8}{10} \selectfont \thepage}
\fancyhead[ER,OL]{\fontsize{8}{10} \selectfont \leftmark}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[EL,OR]{\fontsize{8}{10} \selectfont \thepage}
\fancyhead[ER,OL]{\fontsize{8}{10} \selectfont \nouppercase \leftmark}
}
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Anfang von Dokumententext
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\begin{document}
\pagenumbering{Roman}
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Verzeichnisse
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\tableofcontents
\chapter{Chapter 1}
\section{test section}
\subsection{test section}
\section{test section}
\subsection{test section}
\end{document}
但是当我使用(注释):
\usepackage[subfigure]{tocloft}
\renewcommand\cftchapdotsep{\cftdotsep}
那么以下代码行不再起作用,它看起来像这样:
\titlespacing*{\chapter}{0pt}{-22pt}{7pt}
有人知道如何解决这个问题吗?我非常感谢大家的帮助。提前致谢!
编辑1: 感谢 daleif 让我走到了这一步:
\usepackage{titletoc}
\contentsmargin{2em}
\dottedcontents{section}[3.9em]{}{2.3em}{9.5pt}
\dottedcontents{subsection}[84pt]{}{3.2em}{9.5pt}
\dottedcontents{chapter}[20pt]{\bfseries}{20pt}{9.5pt}
请不要介意这些无意义的标题,这只是为了比较间距。如您所见,行间距仍然不正确,因为所有内容都靠得很近……有人知道如何调整吗?
编辑2:
我现在在章节、节和小节的条目之间添加了垂直空间:
\usepackage{titletoc}
\contentsmargin{2em}
\dottedcontents{chapter}[21pt]{\addvspace{15pt}\bfseries}{20pt}{9.5pt}
\dottedcontents{section}[50pt]{\addvspace{3pt}}{2.3em}{9.5pt}
\dottedcontents{subsection}[89pt]{\addvspace{3pt}}{3.2em}{9.5pt}
但是现在“目录”和“1 第 1 章”之间的间距太大了。有人知道如何调整这个特定的间距吗(现在调整 中的垂直间距\dottedcontents{chapter}[21pt]{\addvspace{15pt}\bfseries}{20pt}{9.5pt}
,因为这是目录本身的间距)?我的意思是,我该如何将“1 第 1 章”和后面的所有内容定位得更靠上一点?到目前为止,我对“目录”的定位很满意。
编辑3: 我还没有找到解决间距问题的方法,但发现我的模板中有相同的特定间距(似乎是正常的,无论您是在 LATEX 还是 Word 中执行此操作),所以我不会再进一步搜索。谢谢大家的帮助!:-)
答案1
这是一个解决方案titletoc
:
\documentclass[12pt,a4paper,twoside]{report} %openright
%Schriftart Arial - ACHTUNG: Compile with XeLaTeX (not PDFLaTeX)!
\usepackage{fontspec}
\defaultfontfeatures{Scale = MatchLowercase}
\setmainfont{Arial}[Scale = 1.0]
%Seitenlayout
\usepackage[top=2.5cm, bottom=2cm, left=2.5cm, right=2.5cm,paper=a4paper]{geometry}
%Zeilenabstand ändern
\usepackage[onehalfspacing]{setspace}
%Graphiken und Bilder
\usepackage{subfig}
%Kopfzeile
\usepackage{fancyhdr}
%Verzeichnisse
\usepackage[notindex, nottoc, numbib]{tocbibind}
%Längenangaben für den Abstand zwischen zwei Absätzen.
\usepackage{parskip}
%Kapitelanzeige und -platzierung im Text
\usepackage[clearempty]{titlesec}
\titleformat{\chapter}{\normalfont\fontsize{16pt}{0}\bfseries}{\thechapter.}{9pt}{}
\titleformat{\section}{\normalfont\fontsize{14pt}{0}\bfseries}{\thesection}{9pt}{}
\titleformat{\subsection}{\normalfont\fontsize{12pt}{0}\bfseries}{\thesubsection}{9pt}{}
\titlespacing*{\chapter}{0pt}{-22pt}{7pt}
\usepackage{titletoc}
\dottedcontents{chapter}[1.5em]{}{1.5em}{0.78pc}
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Formatierung der Kopfzeile
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\setlength{\headheight}{0.6cm}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[EL,OR]{\fontsize{8}{10} \selectfont \thepage}
\fancyhead[ER,OL]{\fontsize{8}{10} \selectfont \leftmark}
\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[EL,OR]{\fontsize{8}{10} \selectfont \thepage}
\fancyhead[ER,OL]{\fontsize{8}{10} \selectfont \nouppercase \leftmark}
}
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Anfang von Dokumententext
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\begin{document}
\pagenumbering{Roman}
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
% Verzeichnisse
% = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
\tableofcontents
\chapter{Chapter 1}
\section{test section}
\subsection{test section}
\section{test section}
\subsection{test section}
\end{document}