Last active
December 31, 2022 23:58
-
-
Save jacintak/71c9978cc5b3d9a2c1b8f82403a31830 to your computer and use it in GitHub Desktop.
[rmarkdown] LaTeX {exam} template with integrated R
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
\begin{coverpages} | |
\begin{center} | |
% provide instructions and details | |
\fbox{\fbox{\parbox{5.5in}{\centering | |
Answer the questions in the spaces provided on the question sheets. \linebreak | |
If you run out of room for an answer, continue on the back of the page.}}} | |
\end{center} | |
\vspace{1in} | |
\makebox[0.9\textwidth]{Name:\enspace\hrulefill} | |
\vspace{0.5in} | |
\makebox[0.9\textwidth]{Student Number:\enspace\hrulefill} | |
\vspace{1in} | |
% add grade table | |
\begin{center} | |
\gradetable[h] | |
\end{center} | |
\end{coverpages} | |
% header and footer | |
\thispagestyle{headandfoot} | |
\firstpageheader{}{Page \thepage\ of \numpages}{} | |
\runningheader{}{Page \thepage\ of \numpages}{} | |
\firstpagefooter{}{}{} | |
\runningfooter{}{}{} | |
\runningheadrule | |
\firstpageheadrule |
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
% define questions and solutions and parts | |
\newcommand{\BQ}{\begin{questions}} | |
\newcommand{\EQ}{\end{questions}} | |
\newcommand{\BS}{\begin{solution}} | |
\newcommand{\ES}{\end{solution}} | |
\newcommand{\BP}{\begin{parts}} | |
\newcommand{\EP}{\end{parts}} | |
% pandoc does not understand parts. Must use {} in markdown | |
\renewcommand{\part}[1][]{\oldpart[1]{}} |
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: "Class Code" | |
subtitle: "Exam Name" | |
date: "`r format(Sys.Date(), '%d-%m-%Y')`" | |
documentclass: exam | |
classoption: [answers, addpoints] # comment to hide answers | |
fontsize: 12pt | |
output: | |
pdf_document: | |
highlight: NULL | |
includes: | |
before_body: cover.tex | |
in_header: preamble.tex | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE, fig.height = 4, fig.width = 4, fig.align = 'center') | |
``` | |
\BQ | |
# Pressure | |
\question[5] Define pressure | |
\BS | |
* Under | |
* Pressure | |
\ES | |
\vspace{\stretch{5}} | |
\newpage | |
# Trees | |
\question Looks at the graph below | |
```{r trees} | |
plot(Height ~ Girth, trees) | |
``` | |
\BP | |
\part[2]{} What is the predictor variable? | |
\BS | |
Girth | |
\ES | |
\vspace{\stretch{2}} | |
\part[3]{} What is the dependent variable? | |
\BS | |
Height | |
\ES | |
\vspace{\stretch{3}} | |
\EP | |
\EQ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment