Created
February 21, 2019 17:26
-
-
Save jwolfson/dc91ba7d28d26768762793e1c6a90a1b to your computer and use it in GitHub Desktop.
Creating a custom LaTeX exam+solution document
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
--- | |
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