pschwime
pschwime

Reputation: 21

LaTeX Code from Kable showing up in R markdown PDF?

I am trying to put a table in my R-markdown report and I like the table that this produces but the laTeX code is showing up in the report. What am I doing wrong? Please see picture and code for reference. I am very new at LaTeX and markdown and really have no idea what I'm doing haha. The data is blacked out in the image for security reasons. Thank you!

PDF output with issues :( (link)

---
title: "Deal Fees by Client Ownership 2008-2018"
output:
  pdf_document: default
  html_document: default
  word_document: default
header-includes:
    - \usepackage{booktabs}
    - \usepackage{caption}
---
```{r, echo = FALSE, message = FALSE}

library(knitr)
library(scales)
library(ggplot2)
library(lubridate)
library(dplyr)
library(reshape2)
library(xtable)
library(kableExtra)
```
```{r, echo = FALSE, message = FALSE, comment=NA, results = 'asis'}


kable(df, format = "latex", caption = "Fee variances ($ millions)", booktabs = T) %>% 
  kable_styling() %>% 
  group_rows("Average", 1, 4) %>% 
  group_rows("Median", 5, 8)

```

Upvotes: 1

Views: 1570

Answers (1)

Hao
Hao

Reputation: 7846

You have a $ in your caption. You need to escape that.

caption = "Fee variances (\\$ millions)"

Upvotes: 5

Related Questions