Here is a reprex :
---
date : 2018-May-27
output:
pdf_document:
latex_engine: xelatex
monofont: \"Computer Modern\"
title: \"Testing Rmarkdown\"
Actaully it is not Computer Modern but its close Relative Latin Modern that is used as default. So you could try:
---
date : 2018-May-26
output:
pdf_document:
latex_engine: xelatex
mainfont: Latin Modern Roman
monofont: Latin Modern Roman
title: "Testing Rmarkdown"
---
```{r,comment = NA}
Gender <- gl(2,1000,labels = c("Men","Women"))
SmokerM <- sample(c("Y","N"),1000,replace = T , prob = c(.3,.7))
SmokerW <- sample(c("Y","N"),1000,replace = T , prob = c(.5,.5))
Smoker <- c(SmokerM,SmokerW)
mydata <- data.frame(Gender,Smoker)
table(mydata$Gender,mydata$Smoker)
knitr::kable(table(mydata$Gender,mydata$Smoker))
```
This is a text in the body of the document.What font is this ? What is
font for the output of table ? How can we change these 2 fonts ? What
other categories of items are there in an Rmarkdown which have different
fonts ?
Since you have an Ubuntu system, you can use fc-list
to see all the fonts installed on your system, that are available for XeLaTeX.
Alternatively, if you do not want to use XeLaTeX, you can use
output:
pdf_document
header-includes:
- \renewcommand*{\ttdefault}{lmr}
in the header.