Change the font of the document name and author name in markdowns

I am using rmarkdown to create a PDF document with a conversion done either in RStudio or using the render() function in R. Can someone give me some pointers for resizing, color, etc. the font used for the title of the documents and the names of the authors? I have made great strides in such things as changing the general font, etc., while editing the front document in the document, but I completely lost it. Please keep in mind that I am not good at speaking LaTeX ...

Thanks for any help

+5
source share
1 answer

Better late than never.

Changing parts of the rmarkdown template by default does not work without using a bit of LaTeX.

First of all, this is a reproducible example:

 --- title: "Lord of the Rings" author: "JRR 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 

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

Using the \pretitle and \preauthor this package, we can override the header style. By default, rmarkdown is used (see code on github )

 \pretitle{\vspace{\droptitle}\centering\huge} \preauthor{\centering\large\emph} 

Now to the code. What have we done:

We imported two packages xcolor and fetamont . The former is required to use colors, and the latter is a package containing the font that we want to use.

In the next three lines, we define 3 new commands. The first ( \eiadfamily ) is used to install the eiad font eiad . The other two ( \myauthor , \mytitle ) simply combine the font and color settings.

Finally, we redefine \preauthor and \pretitle to

 \pretitle{\vspace{\droptitle}\centering\huge\eiadfamily} \preauthor{\centering\large\myauthor} 

(Note that I removed \emph from \preauthor since the slanted version of the ffm font family is not available.)

Here is the result:

enter image description here

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

+1
source

All Articles