I'm outputting a table to PDF via Rmarkdown, and I'm trying to add a hyperlink into my table. It works using markdown syntax when I use kable()
, but when I add any styling using kableExtra
the hyperlink goes away. Below is an example:
This works:
---
output: pdf_document
---
```{r}
library(tidyverse)
data.frame(x = "[click here](https://google.com)") %>%
knitr::kable()
```
and gives me a clickable:
But when I change to:
---
output: pdf_document
---
```{r}
library(tidyverse)
data.frame(x = "[click here](https://google.com)") %>%
knitr::kable() %>%
kableExtra::kable_styling(font_size = 15)
```
I lose the hyperlink formatting:
Anyone know how to maintain the hyperlink formatting while adding additional formatting, when going from RMarkdown to PDF? Thank you!!!
One way would be to use the "latex" option and make use \\href
.
```{r}
data.frame(x = "\\href{https://google.com}{Click here}") %>%
knitr::kable("latex", escape = FALSE) %>%
kableExtra::kable_styling(font_size = 15)