How to use a LaTeX package with R/exams?

后端 未结 2 458
遇见更好的自我
遇见更好的自我 2020-12-21 15:35

I am using exams2moodle() to create exam quizzes. I would like to use some math symbols which require the LaTeX package amssymb. How should I proce

2条回答
  •  没有蜡笔的小新
    2020-12-21 15:56

    In general, you input your symbols into either .Rmd or .Rnw and you can have it rendered with any available engine (e.g. pandoc, mathjax, knitr, etc).

    install.packages("exams")
    
    require(exams)
    

    xWeave is called on each exercise file and creates LaTeX code

    elearn_exam <- c("swisscapital.Rmd", "deriv.Rmd", "ttest.Rmd",
                     "boxplots.Rmd", "function.Rmd", "lm.Rmd", "fourfold2.Rmd")
    
    set.seed(2020-04-16)
    

    exams2moodle() produces an XML file that may be uploaded into Moodle

    It goes from LaTeX to HTML then HTML to XML

    exams2moodle(elearn_exam, n = 3, name = "R-exams")
    

    To add custom LaTeX packages you can modify the preamble as per the answers in this post, i.e. \usepackage

    As described in the linked post, that can either be done direct, i.e.

    ---
    title: "Title"
    author: "Me"
    header-includes:
       - \usepackage{mypackage}
    output:
        pdf_document
    ---
    

    or via a mystyles.sty file in the same directory.

提交回复
热议问题