Latex - Changing The Font of The Document Title and Author Names in Markdown - Stack Overflow
Latex - Changing The Font of The Document Title and Author Names in Markdown - Stack Overflow
Asked 9 years, 9 months ago Modified 2 years, 7 months ago Viewed 4k times
7 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...
latex r-markdown
Share Improve this question Follow edited May 7, 2017 at 15:38 asked May 4, 2015 at 13:25
Martin Schmelzer user3359624
23.9k 8 78 105 324 4 14
Changing individual parts of the default rmarkdown layout does not work without making use of a little bit of 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
---
## 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}\centering\huge}
\preauthor{\centering\large\emph}
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.
\pretitle{\vspace{\droptitle}\centering\huge\eiadfamily}
\preauthor{\centering\large\myauthor}
(Notice that I deleted \emph from \preauthor since an oblique version of the ffm font family is not available.)
Share Improve this answer Follow edited Jan 10, 2018 at 15:51 answered May 7, 2017 at 15:09
Martin Schmelzer
23.9k 8 78 105
Fantastic answer. Worth pointing out that you can simply use - \newcommand*\eiadfamily{\setmainfont{eiad}} if the font is already installed in the
system. – DaveRGP Jan 10, 2018 at 15:50
1 Just adding a CSS code chunk solved it for me:
{css echo=FALSE}
.author {color: black; font-family: cursive }
.title {color: black; font-family: cursive }
Share Improve this answer Follow edited Jun 24, 2022 at 0:16 answered May 12, 2021 at 7:54
loops Ibraheem El Ansari
5,635 2 26 67 91 1 1 7