I want to change the fonts for the title and headings of my document (rendering .rmd to pdf using latex engine xelatex). When trying to render, I keep getting the error:
"compilation failed- error
LaTeX cmd Error: Command '\titlefont' already defined."
even though \titlefont is called only once. I checked the log file and \titlefont only appears once, which is where the log lists the above error. I tried commenting out all other commands to try and isolate the problem, nothing worked.
Below is my header
---
title: "My PDF"
date: "`r Sys.Date()`"
output:
pdf_document:
latex_engine: xelatex
fig_caption: true
fontsize: 12pt
geometry: "left=1.5cm, right=1.5cm"
header-includes:
# - \usepackage{hyperref}
# - \usepackage{booktabs}
# - \usepackage{graphicx}
# - \usepackage{wrapfig}
# - \usepackage{floatflt}
# - \usepackage{geometry}
# - \setlength{\parindent}{15pt}
# - \setlength{\parskip}{8pt}
- \usepackage{fontspec}
# - \usepackage{titlesec}
- \setmainfont{Georgia}
- \newfontfamily\titlefont{Georgia}
# - \newfontfamily\subtitlefont{Latin Modern Roman}
# - \newfontfamily\headingfont{Latin Modern Roman}
# - \newfontfamily\captionfont{Latin Modern Roman}
# - \DeclareCaptionFont{captionfont}{\captionfont}
# - \captionsetup{font=captionfont}
---