在目录末尾手动添加内容

在目录末尾手动添加内容

我有以下代码:

\documentclass[12pt]{book}
\usepackage[francais, english]{babel}

\begin{document}
\tableofcontents
\chapter{Chapter}
\section{Section}
~\cite{cr:sas:12}
% ------------------------------------------
% Bibliography
\addtocontents{toc}{\vskip 4mm}
\addcontentsline{toc}{alone}{\protect\numberline{}Bibliography}
\bibliographystyle{alpha}
\bibliography{thesis}
% ------------------------------------------
% List of figures
\addcontentsline{toc}{alone}{\protect\numberline{}List of Figures}
\listoffigures
\cleardoublepage
% ------------------------------------------
% List of tables
\addcontentsline{toc}{alone}{\protect\numberline{}List of Tables}
\listoftables
\cleardoublepage
% ------------------------------------------
% List of Definitions
\chapter*{List of Definitions}
\markboth{List of Definitions}{List of Definitions}
\addcontentsline{toc}{alone}{\numberline{}List of Definitions}
\makeatletter
\@starttoc{lod}
\makeatother
\end{document}

生成的目录如下: 在此处输入图片描述

Bibliography有人知道为什么、等的行List of Figures生成得不好吗?我的意思是我希望看到以下内容:

1 Chapter                                                3
  1.1 Section .........................................  3


Bibliography ..........................................  3
List of Figures .......................................  5
List of Tables ........................................  9
List of Definitions ................................... 11

答案1

将您手动插入的每个 ToC 条目格式化为类型chapter而不是alone

在此处输入图片描述

\documentclass{book}

\begin{document}
\tableofcontents
\chapter{Chapter}
\section{Section}
% ------------------------------------------
% Bibliography
\addtocontents{toc}{\vskip 4mm}
\addcontentsline{toc}{chapter}{\protect\numberline{}Bibliography}
\chapter*{Bibliography}
%\bibliographystyle{alpha}
%\bibliography{thesis}
% ------------------------------------------
% List of figures
\addcontentsline{toc}{chapter}{\protect\numberline{}List of Figures}
\listoffigures
\cleardoublepage
% ------------------------------------------
% List of tables
\addcontentsline{toc}{chapter}{\protect\numberline{}List of Tables}
\listoftables
\cleardoublepage
% ------------------------------------------
% List of Definitions
\chapter*{List of Definitions}
\markboth{List of Definitions}{List of Definitions}
\addcontentsline{toc}{chapter}{\numberline{}List of Definitions}

\end{document}

如果你希望不是让条目按原样缩进,删除插入\protect\numberline{}中包含的宏\addcontentsline

在此处输入图片描述

为了将点(或引线)添加为手动添加的 ToC 条目的一部分,您可以将它们作为类型插入dchapter而不是chapter在序言中使用以下附加内容:

\usepackage{etoolbox}
\makeatletter
\let\l@dchapter\l@chapter
\patchcmd{\l@dchapter}% <cmd>
  {\hfil}% <search>
  {{\normalfont\leaders\hbox{$\m@th
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
        mu$}\hfill}}% <replace>
  {}{}% <success><failure>
\makeatother

以上插入了点作为引导(直接\@dottedtocline取自latex.ltx),而以前只有\hfil。此外,为了使领导者与section类型条目对齐,他们已被设置为\normalfont

在此处输入图片描述

相关内容