Skip to content

Instantly share code, notes, and snippets.

@jwolfson
Created February 21, 2019 17:26
Show Gist options
  • Save jwolfson/dc91ba7d28d26768762793e1c6a90a1b to your computer and use it in GitHub Desktop.
Save jwolfson/dc91ba7d28d26768762793e1c6a90a1b to your computer and use it in GitHub Desktop.
Creating a custom LaTeX exam+solution document
---
---
title: "`r sprintf('Exam Questions%s', ifelse(params$solutions, ' and Solutions', ''))`"
author: ""
date: ""
output: pdf_document
params:
solutions: TRUE
---
```{r echo=FALSE, results='asis'}
cat(sprintf("Value of 'solutions' parameter: %s\n", as.character(params$solutions)))
```
```{r echo=FALSE, results='asis'}
cat('This is a question with LaTeX: Compute the integral $\\int \\frac{1}{x} dx$.')
```
```{r echo=FALSE, results='asis'}
if(params$solutions) {
cat('This is a solution with LaTeX: $\\int \\frac{1}{x} dx = \\log(x) + C$.')
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment