迟做总比不做好。
如果要更改默认的rmarkdown布局中的个别部分,则需要使用一些LaTeX。
首先,这里有一个可重现的示例:
---
title: "Lord of the Rings"
author: "J. R. R. Tolkien"
header-includes:
- \usepackage{xcolor}
- \usepackage{fetamont}
- \newcommand*\eiadfamily{\fontencoding{OT1}\fontfamily{eiad}\selectfont}
- \newcommand{\mytitle}{\eiadfamily}
- \newcommand{\myauthor}{\ffmfamily \textcolor{blue}}
- \pretitle{\vspace{\droptitle}\centering\huge\eiadfamily}
- \preauthor{\centering\large\myauthor}
output: pdf_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## Chapter 1
在这种方法中,我们不需要包含自定义的TeX模板。我们利用rmarkdown使用LaTeX包
titling
创建文档标题的事实。文档可以在
此处找到。
通过该包的命令
\pretitle
和
\preauthor
,我们可以重新定义标题的样式。rmarkdown使用的默认值为(请参见
Github上的代码)。
\pretitle{\vspace{\droptitle}\centering\huge}
\preauthor{\centering\large\emph}
现在来看代码。我们做了什么:
我们导入了两个包,xcolor
和fetamont
。第一个包用于使用颜色,而后一个包则是包含我们想要使用的字体的包。
接下来的三行代码定义了三个新命令。第一个命令(\eiadfamily
)用于将字体族设置为eiad
。
另外两个命令(\myauthor
、\mytitle
)则只是结合了字体和颜色的设置。
最后,我们重新定义了\preauthor
和\pretitle
。
\pretitle{\vspace{\droptitle}\centering\huge\eiadfamily}
\preauthor{\centering\large\myauthor}
请注意,我从
\preauthor
中删除了
\emph
,因为 ffm 字体家族的斜体版本不可用。
以下是结果:
可以在
http://www.tug.dk/FontCatalogue/ 找到可用字体的概述。