2

I am a new LaTeX and RMarkdown user. I am currently compiling reports using RMarkdown (in RStudio) but am unsure how to centre and bold one of my headings? For example, my document looks like this:

---
title: <center> <h1>Call Centre Report</h1> </center>
mainfont: Arial
output:
  pdf_document:
    latex_engine: xelatex
sansfont: Arial
fig_crop: false
toc: true
classoption: landscape
fontsize: 14pt
geometry: margin=0.5in
header-includes:
- \usepackage{booktabs}
---
<style>
  .main-container {
    max-width: 1200px !important;
  }
</style>

```{r global_options, R.options=knitr::opts_chunk$set(warning=FALSE, message=FALSE)}
```
\newpage

# Iris 

```{r fig.width=18, fig.height=7, echo=FALSE, comment=" "}
library(ggplot2)
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width, colour = Species)) +
   geom_point() +
   theme_classic()
```

I wish to have the "Iris" heading centred and bold while retaining it's format as a heading to appear in the TOC, but am unsure how to do so?

Any help would be greatly appreciated.

2

A package that doesn't clash wit the pandoc default.latex template is sectsty

At the end of the yaml, direct under header-includes add the package

...
header-includes:
- \usepackage{booktabs}
- \usepackage{sectsty} \sectionfont{\centering \emph}
---

See the package manual for more option

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.