我正在尝试单独制作与图片中所示的目录。有模板吗?我只有“目录”,但没有附加文档。
我对这个 Stack exchange 模板的问题是:
- 我想要的是“目录”,而不是顶部的“目录”
- 我不希望将“致谢”和“表格列表”列为章节,而是希望如附图所示。
- 我想手动控制页面列表,因为在我的代码中您可以看到所有的页码都是 2,但我希望它们如图片中所附。
最小示例:
\documentclass{article}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\usepackage{titlesec}
\titleformat{\subsection}{\normalfont\large\bfseries}{\thesubsection.}{1em}{}
\titleformat{\subsubsection}{\normalfont\normalsize\bfseries}{\thesubsubsection)}{1em}{}
\titleformat{\paragraph}[runin]{\normalfont\normalsize\bfseries}{\theparagraph)}{1em}{}
\titleformat{\subparagraph}[runin]{\normalfont\normalsize\bfseries}{\thesubparagraph)}{1em}{}
\usepackage{tocloft}
\setlength{\cftsecnumwidth}{1em}
\setlength{\cftsubsecnumwidth}{2em}
\setlength{\cftsubsubsecnumwidth}{2.5em}
\setlength{\cftparanumwidth}{3.8em}
\setlength{\cftsubparanumwidth}{3.8em}
\setlength{\cftsecindent}{0em}
\setlength{\cftsubsecindent}{1.8em}
\setlength{\cftsubsubsecindent}{4.1em}
\setlength{\cftparaindent}{5.9em}
\setlength{\cftsubparaindent}{7.7em}
\begin{document}
\tableofcontents
\section{ACKNOWLEDGMENTS}
\section{LIST OF TABLES}
\section{Introduction}
\subsection{Background}
\subsection{Evolution of Missing Data Estimation Method}
\subsection{Missing Data Mechanism}
\subsubsection{Missing Completely at Random}
\subsubsection{Missing at Random}
\subsubsection{Missing not at Random}
\end{document}
答案1
使用
\section*
和\addcontentsline
。参见下面的代码。请参阅下面的代码。
只需将
page
计数器设置为所需的值(参见下面的代码,其中\MyNum
命令允许您指定所需的页码)。在评论中,有人要求页面边距为 1 英寸。可以使用以下方法实现
\usepackage[margin=1in]{geometry}
我隐藏了原始代码中对问题/解决方案不重要的部分。获得所需结果的最简单方法是使用\cftsetindents
分段单元的命令
\documentclass{article}
\usepackage[margin=1in]{geometry}
\usepackage{tocloft}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}
\renewcommand\contentsname{\MakeUppercase{Table of Contents}}
\renewcommand\cfttoctitlefont{\hfill\Large\bfseries}
\renewcommand\cftaftertoctitle{\hfill\null\vskip.5\baselineskip}
\renewcommand\cftsecleader{\cftdotfill{\cftdotsep}}
\renewcommand\cftbeforesecskip{2pt}
\renewcommand\cftbeforesubsecskip{2pt}
\renewcommand\cftbeforesubsubsecskip{2pt}
\cftsetindents{section}{0pt}{1em}
\cftsetindents{subsection}{1em}{2em}
\cftsetindents{subsubsection}{2.5em}{2.5em}
\renewcommand\cftsecfont{\normalfont}
\renewcommand\cftsecpagefont{\normalfont}
\newcommand\MyNum[1]{%
\newpage
\setcounter{page}{#1}%
}
\begin{document}
\tableofcontents
\MyNum{5}
\section*{ACKNOWLEDGMENTS}
\addcontentsline{toc}{section}{ACKNOWLEDGMENTS}
\MyNum{8}
\section*{LIST OF TABLES}
\addcontentsline{toc}{section}{LIST OF TABLES}
\MyNum{9}
\section{Introduction}
\subsection{Background}
\MyNum{10}
\subsection{Evolution of Missing Data Estimation Method}
\MyNum{12}
\subsection{Missing Data Mechanism}
\subsubsection{Missing Completely at Random}
\MyNum{14}
\subsubsection{Missing at Random}
\MyNum{15}
\subsubsection{Missing not at Random}
\end{document}
评论:
如果babel
已加载,则行
\renewcommand\contentsname{\MakeUppercase{Table of Contents}}
不会有任何效果。在这种情况下,必须使用
\addto\captions<language>{\renewcommand\contentsname{\MakeUppercase{Table of Contents}}}
正如本网站其他一些答案所述。
答案2
titletoc
这是另一个解决方案,使用 titlesec
和etoolbox
包。后者允许在布尔值为“true”时自动将未编号的部分添加到目录中,将命令合并\addcontentsline…
到 .\titleformat{\section}
命令中。我还在部分编号后添加了一个点,如 OP 的示例所示。
\documentclass[11pt, a4paper, twoside]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[pagestyles, explicit]{titlesec}%
\usepackage[leftlabels]{titletoc}%
\usepackage{etoolbox}
\newbool{addtoc}%initial value: false
\titleformat{\section}[display]%
{\bfseries\Large\filcenter}
{\LARGE\thesection}
{0.5pc}
{\vspace{0.5pc}\Huge\MakeUppercase{#1}}%
\titleformat{name=\section, numberless}[display]
{\bfseries\large\filcenter}
{}
{0.5pc}
{\vspace{0.5pc}\MakeUppercase{#1}}%
[\ifbool{addtoc}{\addcontentsline{toc}{section}{#1}}{}]%
\titlecontents{section}[2em]{\smallskip}%\vspace{1cm}
{\contentslabel[\thecontentslabel.]{1em}}%numbered
{\hspace*{-1em}}%numberless
{\dotfill\contentspage}[\medskip]%
%
\titlecontents{subsection}[4em]{\smallskip}%
{\contentslabel[\thecontentslabel.]{2em}}%numbered
{\hspace*{-1em}}%{-1em}}%numberless
{\dotfill\contentspage}[\smallskip]%\vspace{-0,25ex}
%
\titlecontents{subsubsection}[6.75em]{}%
{\contentslabel[\thecontentslabel.]{2.75em}}%numbered
{\hspace*{-1em}}%numberless
{\dotfill\contentspage}[\smallskip]
\renewcommand*{\contentsname}{Title of contents}
\begin{document}
\tableofcontents
\booltrue{addtoc}
\newpage
\section*{ACKNOWLEDGMENTS}
Blahblahblah
\newpage
\section{INTRODUCTION}
\subsection{Background}
\subsection{Evolution of Missing Data Evolution Method Evolution of Missing Data Evolution Method}
\subsection*{Missing Data Mechanisms}
\subsubsection{Missing Completely at Random Missing Completely at Random Missing Completely}
\subsubsection{Missing at Random}
\subsection{Missing Not at Random}
\subsection{Strategies for Missing Data}
\newpage
\section{LITERATURE REVIEW}
\end{document}