exams2pandoc 错误消息 - 模板无效

exams2pandoc error message - invalid template

我是 R 的新手,对 R 考试的基础知识知之甚少。我已经成功地使用它来制作用于打印 (exams2pdf) 和上传到 canvas 的考试,但是当我尝试 运行 exams2pandoc:

时,我不断收到以下错误
Error in make_exams_write_pandoc(name = name, type = type, template = template,  : 
  invalid template: exactly 9 '#-' lines required (and 0 found)

我不明白它在告诉我什么,需要一点指导。

注意 - 在我试图找出问题的过程中,exams2pandoc 确实成功地在其中一个示例文件(例如 switzerland.Rmd)上输出了一个 docx 文件,可能一次或两次,但现在无论文件如何,我都会不断收到上面的错误消息。

我不确定此时该尝试什么(例如,调整其中一个模板文件),我也不太清楚该怎么做。在此先感谢您的帮助。

您的问题听起来 exams2pandoc() 随包一起提供的模板 modified/corrupted。我会推荐 re-installing exams 包。之后 exams2pandoc(c("swisscapital.Rmd", "deriv.Rmd")) 应该再次工作并生成文件 pandoc1.docx.

如果您想修改模板,这是可能的,但没有很好的记录。此外,模板格式可能会在未来的版本中发生变化,它仍然有点特别。默认模板是 LaTeX 文件 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}

您看到 #- 行用于定义模板文件中包含某些占位符的几个部分。如果你想省略问题 header 最简单的方法是创建一个文件,比如 myplain.tex,其中注释了这一行:

  %% \textbf{##Questionheader##}\

类似地,可以对其他部分进行注释或修改。然后你可以调用 exams2pandoc(..., template = "myplain.tex").