I am using Bookdown and Rmarkdown to compose a technical book for Stata users. I would like to include Stata highlighting syntax in the chunks of code, but I am not interested in actually executing Stata from Rstudio. I just want the syntax highlighting.
I learned here that it is possible to use highlightjs but I have no idea how to include it in my .Rmd files.
I would like to be able to include something like the following and get it syntax highlighted.
```stata
sysuse auto, clear
reg mpg length
```
I highly appreciate your help. Thanks.
Now you can highlight your stata code, by using the latest R packages related to knitting.
rmarkdown
Ver. 2.10knitr
: Ver. 1.33bookdown
: Ver. 0.22You may also have to [u]se a Pandoc version not bundled with the RStudio IDE. I use a Pandoc Ver. 2.14.0.3.
---
title: "Untitled"
author: "author"
output:
bookdown::pdf_document2: default
---
- `rmarkdown`: Ver. `r packageVersion("rmarkdown")`
- `knitr`: Ver. `r packageVersion("knitr")`
- `bookdown`: Ver. `r packageVersion("bookdown")`
- (`pandoc`: Ver. `r rmarkdown::pandoc_version()`)
```stata
sysuse auto, clear
reg mpg length
```
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With