I'm creating a small package for generating exams with randomly ordered questions (and responses on multiple choice items) and the R part is going fine, but now I need a little more control over the resulting LaTeX that is created when rendering a .pdf.
Here is my issue: questions and their corresponding response items can be split across multiple pages, which is not ideal. I've come up with a suitable LaTeX solution by encapsulating the question items within a minipage
. The original .tex
file looks something like this:
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\item
Which bear is best?
A. Teddy bear\\
B. Black bear\\
C. Grizzly bear\\
D. Honey bear\\
E. Polar bear
\item
Which beer is best?
A. Miller Lite\\
B. Naturdays\\
C. Leine's\\
D. Hamm's\\
E. PBR
\end{minipage}
And my minipage
solution is to do something like this:
\begin{enumerate}
\def\labelenumi{\arabic{enumi}.}
\begin{minipage}{\linewidth}
\item
Which bear is best?
A. Teddy bear\\
B. Black bear\\
C. Grizzly bear\\
D. Honey bear\\
E. Polar bear
\end{minipage}
\begin{minipage}{\linewidth}
\item
Which beer is best?
A. Miller Lite\\
B. Naturdays\\
C. Leine's\\
D. Hamm's\\
E. PBR
\end{minipage}
The problem is that I don't know how to do this with RMarkdown and R in a one step process. Ideally, a user would have an .Rmd file in which they simply do something like...
---
title: Some test
output: pdf_document
---
```{r}
library(examgen)
output_questions("/path/to/questions.json")
```
and the LaTeX will be formatted appropriately, but I think this is not simply an issue of including a custom .tex
file (I could be wrong here). I could easily create a shell script that inserts the minipages
s at the appropriate place and then again renders a .pdf with pdflatex
or whatever was being used, but obviously this is not the most user friendly. I'd also like this package to be able to output .html as well.
I can provide more details about the R code if that's relevent.