Changing the font of the document title and author names in markdown

I'm using rmarkdown to produce a pdf document with conversion done either in RStudio or by using the render() function in R. Can anyone give me some pointers for changing the size, colour etc. of the font used for the document title and author names? I have made a lot of progress with things like changing the overall font and so on by editing the front matter in the document but I am completely lost on this one. Please bear in mind that I do not speak LaTeX very well...

Thanks for any help


Better late than never I guess.

Changing individual parts of the default rmarkdown layout does not work without making use of a little bit of LaTeX.

First of all, here is a reproducible example:

---
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}centeringhugeeiadfamily}
  - preauthor{centeringlargemyauthor}
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```


## Chapter 1

In this approach, we do not need to include a custom TeX template. We make use of the fact that rmarkdown uses the LaTeX package called titling to create the document header. The documentation can be found here.

Using the commands pretitle and preauthor of that package we can redefine the style of the header. The defaults that are used by rmarkdown are (see code on github)

pretitle{vspace{droptitle}centeringhuge}
preauthor{centeringlargeemph}

Now to the code. What did we do:

We imported two packages, xcolor and fetamont . The first one is needed to make use of colors and the latter one is a package containing a font we aim to use.

With the next three lines we define 3 new commands. The first one ( eiadfamily ) is used to set the font family to be eiad . The other two ( myauthor , mytitle ) just combine the setting of a font and a color.

Lastly we redefine preauthor and pretitle to

pretitle{vspace{droptitle}centeringhugeeiadfamily}
preauthor{centeringlargemyauthor}

(Notice that I deleted emph from preauthor since an oblique version of the ffm font family is not available.)

Here is the result:

在这里输入图像描述

An overview of available fonts can be found at http://www.tug.dk/FontCatalogue/.

链接地址: http://www.djcxy.com/p/33444.html

上一篇: Cleanthesis TeX主题不会创建PDF

下一篇: 以降价方式更改文档标题和作者姓名的字体