Skip to content

Instantly share code, notes, and snippets.

@wmay
Last active December 2, 2019 02:30
Show Gist options
  • Save wmay/c7c68a5cb385c56ff61582a15a0a88c6 to your computer and use it in GitHub Desktop.
Save wmay/c7c68a5cb385c56ff61582a15a0a88c6 to your computer and use it in GitHub Desktop.
Simple Latex knitr engine
---
title: "Latex engine test"
author: "William May"
date: "December 1, 2019"
output: pdf_document
---
```{r setup, include=FALSE}
library(knitr)
opts_chunk$set(echo = TRUE)
# a simple Latex engine
eng_latex <- function(options) {
# the original latex code is also the output
out <- c("\\bigskip", options$code)
# don't process the latex output
options$results <- "asis"
engine_output(options, options$code, out)
}
knitr::knit_engines$set(latex = eng_latex)
```
We should see the output of this latex code:
```{latex test}
\begin{enumerate}
\item Cat
\item Dog
\end{enumerate}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment