Hi,
I found a way to do it for PDF, using LaTeX commands:
---
title: "RCommunityForum"
author: "PJ"
date: "13/07/2019"
output:
word_document: default
pdf_document:
extra_dependencies: xcolor
html_document:
df_print: paged
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
\```
## R Markdown
\definecolor{fancyTextColor}{HTML}{4284f5}
\definecolor{hightlightColor}{HTML}{FFFF66}
This is an R Markdown document. \colorbox{hightlightColor}{Markdown} is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
When you click the **Knit** button \textcolor{fancyTextColor}{a document will be generated} that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
```{r cars}
summary(cars)
\```
* Careful if you copy paste this in markdown since I had to use \ to format the code as it uses ``` as well
Here are some websites for extra info
Grtz
PJ