标题

概述

使用 Quarto 呈现的 HTML 页面在文章开头包含一个格式化的标题块。标题块包含标题、副标题、作者、日期、doi 和摘要。

标题块的简单示例如下

Document with header reading: Summarizing Output for Reproducible Documents. Below is Author (Nora Jones), Affiliation (Spacely Sprockets), Published (5/4/2018). Below that is a description which reads: A summary of best practices for summarizing output of reproducible scientific documents.

标题块将自动布局文件正文中的元素。如果你愿意,可以使用 title-block-style 来控制这种行为。

有三个选项可供选择:

default 默认

默认标题块处理方法是创建一个较小的字体,并将各种标题元素集中到文档标题块的样式组中。

plain 普通

普通处理将进行所有标题元素处理(收集和组织元素),但不会应用默认标题块样式。

none

none 完全禁用标题块处理。内容不会被处理或组织,标题块将从 Pandoc 逐字输出。

标题横幅

此外,如果您想要更突出的标题块,可以使用 title-block-banner 创建横幅式标题块。横幅式标题块会将标题、副标题、描述和类别置于插图上方的横幅中. 如:

---
title-block-banner: true
---

将呈现类似的标题块:

Title block with title and description against a blue background up top, and below a section with author, affilitation, and date published.

自定义背景

在这种情况下,横幅的颜色会根据主题自动确定。不过,您可以通过提供 CSS 颜色(例如"#FFDDFF"红色)或用作背景的图片路径来控制横幅背景。例如,要使用横幅图片,您可以写道:

---
title-block-banner: images/banner.jpeg
---

会出现类似的横幅标题块:

Title block with title and description against an image background up top, and below a section with author, affilitation, and date published.

如果提供了明确的背景颜色或图像,Quarto 会假定背景颜色将与正文背景颜色形成对比,并自动使用正文背景颜色作为横幅上的文字颜色。

前景色 |Foreground Color

您还可以使用 title-block-banner-color 指定横幅文字的颜色,并提供 CSS 颜色(例如 "#FFDDFF"red)。

日期 | Date

Quarto 在标题块中包含文档的 date。除了编写标准日期外,您还可以使用一些特殊关键字来生成日期。today 将提供当前日期,并将当前时间设为 0, now 将提供当前日期和时间;last-modified 将提供文件本身的修改日期和时间。

格式化 | Formatting

当使用 defaultplain 样式输出标题块时,Quarto 会根据文档的语言 (lang)自动格式化日期。您可以在文档正文中指定 date-format 来控制格式。例如

---
title: Summarizing Output for Reproducible Documents
date: 2018-05-04
date-format: short
---

有关日期格式的更多信息,请参阅 Quarto 日期格式参考

元数据标签 | Metadata Labels

标题块中包含的元数据标签(labels)的默认值已正确本地化,但您可能希望为元数据提供自己的标签。可以使用以下方法自定义标签:

Option Label Styles
author-title Authors plain, default
affiliation-title Affiliations plain, default
abstract-title Abstract plain, default, none
description-title Description plain, default
published-title Date Published plain, default
doi-title DOI plain, default

自定义标题页

要了解有关提供完整自定义标题块的更多信息,请参阅模板局部文档