SCM

Forum: support

Monitor Forum | Start New Thread Start New Thread
RE: exams2pdf using Rmd gives errors [ reply ]
By: Joris Meys on 2017-05-23 11:46
[forum:45147]
Thank you for your swift response! And you're right about your extra comments, thank you.

RE: exams2pdf using Rmd gives errors [ reply ]
By: Achim Zeileis on 2017-05-23 11:08
[forum:45145]
Joris, thanks for raising this issue. Our examples in the package never showed R _input_ (only output) and hence we never noticed this problem.

The root is that by default pandoc/knitr turn on code decoration (with the {Shaded} environment) which requires the LaTeX template to define this environment. The simple workaround with the current CRAN release is to modify your .Rmd exercises to use the highlight=FALSE option in the code chunks, e.g.,

```{r calculate, highlight=FALSE}
abs(round((Mean - mu)/sqrt(Var/n), digits = 3))
```

In the development version of "exams" here on R-Forge I just committed a version that avoids this problem. By default highlight=FALSE now so that the .Rmd exercises do not have to do this themselves. Of course, the individual exercises can overrule the new default by setting highlight=TRUE explicitly.

The devel package now also includes a plain-highlight.tex template that has the necessary environments defined. Also, the lm.Rmd exercise was extended to show the code input for solving the exercise. Compare:

exams2pdf("lm.Rmd")
exams2pdf("lm.Rmd", highlight = TRUE, template = "plain-highlight.tex")

Two further comments on your exercises that have nothing to do with the problem:

- Personally, I wouldn't include library("exams") in every exercise but simply assume that this was done prior to calling exams2xyz(). Alternatively, I would use the fully qualified function calls, e.g., exams::fmt(tstat) if I don't want to rely on the package being attached to the search path.

- The col='blue' in the histogram uses a lot of highly saturated colors which can be distracting to look at for a longer time. Something like col='lightgray' is visually less invasive.

RE: exams2pdf using Rmd gives errors [ reply ]
By: Joris Meys on 2017-05-23 07:16
[forum:45138]

Histogram.Rmd (4) downloads
Second file

exams2pdf using Rmd gives errors [ reply ]
By: Joris Meys on 2017-05-23 07:15
[forum:45137]

CompareSingleMean.Rmd (4) downloads
I am testing the exams package, using two simple examples. Files in attachment. If I try the following:

library(exams)
questions <- list("CompareSingleMean.Rmd",
"Histogram.Rmd")

# Quickly examine the output
exams2html(questions, edir = "Questions")
exams2pdf(questions, edir = "Questions")

Then the html file is displayed correctly, but the PDF file is not. I get following errors:

LaTeX errors:
exercise1.tex:26: LaTeX Error: Environment Shaded undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help
Your command was ignored.
exercise1.tex:27: LaTeX Error: Environment Highlighting undefined.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help
Your command was ignored.
exercise1.tex:29: LaTeX Error: \begin{solution} on input line 13 ended by \end{
Highlighting}.

See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help
exercise1.tex:30: LaTeX Error: \begin{solution} on input line 13 ended by \end{
Shaded}.

Not sure if I'm doing something wrong, but I tried to follow the examples in the package as close as possible

Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge