I'm new to R and barely know enough to make the basics of R-exams work. I've successfully used it to make exams for printing (exams2pdf) and for uploading into canvas, but I keep getting the following error when I try to run exams2pandoc:
Error in make_exams_write_pandoc(name = name, type = type, template = template, :
invalid template: exactly 9 '#-' lines required (and 0 found)
I don't understand what it's telling me and need a little direction.
Note - In the midst of me trying to figure out the problem, exams2pandoc did successfully output a docx file, maybe once or twice, on one of the sample files (e.g., switzerland.Rmd), but now I keep getting the error message above regardless of the file.
I'm not sure what to try at this point (e.g., tweaking one of the template files), nor do I quite know how to do that. Thanks in advance for any assistance.
Your problem sounds like the exams2pandoc()
templates shipped along with the package have been modified/corrupted. I would recommend re-installing the exams
package. After that exams2pandoc(c("swisscapital.Rmd", "deriv.Rmd"))
should work again and produce a file pandoc1.docx
.
If you want to modify the template, this is possible but poorly documented. Also the template format might change in future versions, it's still a bit ad hoc. The default template is a LaTeX file plain.tex
:
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{a4wide,color,Sweave,url,amsmath,booktabs,longtable}
\begin{document}
%% Exam ##ID##
%% ##Date##
\begin{enumerate}
#-
\item
#-
\textbf{##Questionheader##}\\
#-
##Question##
#-
\begin{enumerate}[(a)]
\item ##Questionlist##
\end{enumerate}
#-
\textbf{##Solutionheader##}\\
#-
##Solution##
#-
\begin{enumerate}[(a)]
\item ##Solutionlist##
\end{enumerate}
#-
#-
\end{enumerate}
\end{document}
You see that #-
lines are used to define several sections in the template file which contain certain placeholders. If you want to omit the question header it's simplest to create a file, say myplain.tex
, where this line is commented:
%% \textbf{##Questionheader##}\\
Analogously, other parts could be commented or modified. And then you can call exams2pandoc(..., template = "myplain.tex")
.