我应该将 \title、\author、\date 放在序言中还是放在 \begin{document} 之后?

我应该将 \title、\author、\date 放在序言中还是放在 \begin{document} 之后?

提出这个问题的动机

如果这对你来说看起来太基础了,请原谅我,但到目前为止还没有人在评论中向我指出一个问题命令\title(以及另外两个元数据命令\author\date)应放在前言中。到目前为止,我的做法是将它们写在后面\begin{document}。在标题的 \thetitle、\theauthor 和 \thedate 不起作用组织序言的最佳实践,用户唐切里提到写它们“快到最后”序言。

我咨询了再次,它似乎倾向于将这些放在序言中。以下是取自 lshort(英文版第 8 页)的示例代码。

\documentclass[a4paper,11pt]{article}
% define the title
\author{H.~Partl}
\title{Minimalism}
\begin{document}
% generates the title
\maketitle
% insert the table of contents
\tableofcontents
\section{Some Interesting Words}
Well, and here begins my lovely article.
\section{Good Bye World}
\ldots{} and here it ends.
\end{document}

然而,在一些在线教程中,它们是在之后写的\begin{document}

问题:

标准做法是什么?每种用法各有什么优点或缺点?

例如,我知道上述帖子中的答案;但除此之外,还有其他事情需要考虑吗?首先,在大多数情况下,我不会收到编译错误或警告。虽然我不记得当这些命令写在其他地方时我是否遇到过这样的编译错误。

答案1

从概念上讲,这些是有关文档的“元数据”,而不是文档本身的一部分。因此,我更喜欢将它们设置在序言中。

正如其他人所指出的,对于标准类,在没有改变类别代码的包的情况下,没有技术原因要求优先选择一种方法而不是另一种方法。\maketitle但是,对于自动发出的类,设置 可能是必不可少的\authorETC。在序言中。如果元数据被拾取以hyperref添加到 PDF 信息中,情况也是如此。

答案2

使用 package 时,babel最好在 之后使用它\begin{document}。这样,简写就会生效,并可用于连字符点:

\documentclass[11pt]{scrreprt}
\usepackage[ngerman]{babel}  
\begin{document}
\title{Das ist ein Mustertext, der dazu da ist, um Textsatz"=Problematik
    bzw. Textsatz"=Schwierigkeit eindeutig zu demonstrieren}
\author{foo}
\maketitle
\end{document}

在此处输入图片描述

在序言中,您必须设置标题,而不能使用简写:

\documentclass[11pt]{scrreprt}
\usepackage[ngerman]{babel}  
\title{Das ist ein Mustertext, der dazu da ist, um Textsatz-Problematik
    bzw. Textsatz-Schwierigkeit eindeutig zu demonstrieren}
\author{foo}
\begin{document}
\maketitle
\end{document}

在此处输入图片描述

可以在\title使用之前在序言中激活简写,但那是另一个命令并且可能会导致其他问题...

答案3

尝试这个:

\documentclass{tufte-book}
\begin{document}
\title{This is a test}

\end{document}

正如您所看到的,有些课程固执己见,希望您将其放在序言中。从记忆中,它可能还会影响其他包,例如hyperref。最好将其放在 Leslie Lamport 认为它应该属于的位置,即序言中。

答案4

有些类需要放置 和类似的\title声明\author \begin{document}。例如,revtex这是向 APS、AIP 等实体期刊提交科学论文的标准类别。恕我直言,最好将这些命令放在序言中。出于某些原因,revtex使用了不同的方法。我不知道具体原因。也许吧,因为应该在这个类别中\begin{abstract}...\end{abstract}先行。\maketytle

相关内容