报告标题页上的目录

报告标题页上的目录

我正在写一篇论文,只要是草稿,我就想将非内容量保持在最低限度。也就是说,我希望我的标题页只是一个标题,其中包含论文名称、简短摘要和目录。

目录本身对我来说是个问题。使用 report 时,目录会为自己保留一整页,可能是因为章节式标题。我尝试了几个包(如 minitoc、titletoc 等),但都无济于事,我尝试重新定义命令,但这只在文章模式下有效。

所以我只需要生成目录的内容,而不需要标题(或者不需要强制新页面的标题)。

答案1

使用内部命令\@starttoc{toc}排版目录的内容。此外,使用notitlepageclass 选项。

\documentclass[notitlepage]{report}

\makeatletter
\newcommand*{\toccontents}{\@starttoc{toc}}
\makeatother

\begin{document}

\author{(Author)}
\title{(Title)}
\maketitle

\toccontents

\chapter{foo}

\end{document}

在此处输入图片描述

答案2

一个技巧可能是使用选项notitlepage,所以\maketitle不会生成包含数据的页面。然后我们可以让 LaTeX 认为\chapter什么都不做(请注意,这是在环境内部,重新定义命令是安全的,因为重新定义将在环境结束时消失;不要在没有将包含\renewcommand在组中的情况下执行此操作;这肯定算是一种黑客行为):

\documentclass[notitlepage]{report}

\usepackage{lipsum}
\begin{document}

\begin{titlepage}
\thispagestyle{empty}

\title{A draft of my thesis}
\author{A. U. Thor}
\maketitle

\vfill

\begin{abstract}
\lipsum[2]
\end{abstract}

\vfill

\renewcommand{\chapter}[2]{}
\tableofcontents

\vfill

\end{titlepage}

\chapter{Intro}
\lipsum[1]
\end{document}

这是可行的,因为\tableofcontents确实\chapter*{...}如此,\chapter用两个参数重新定义不做任何事情将忽略*和真实参数。您将没有目录标题;您可以通过以下方式添加一个

\begin{center}
\bfseries\contentsname
\end{center}

就在之前\tableofcontents,这样结果就会类似于摘要的标题。

对于更简洁的版本,应该使用\makeatletter\makeatother访问\@starttoc(如在 lockstep 中)答案或\tableofcontents使用进行修补etoolbox。由于这是仅在初步版本中使用的快速破解方法,我相信这是最简单的技巧。

相关内容