ex2pdf: Generation of Exercise Sheets and Exams in PDF Format

Description Usage Arguments Details Value Author(s) Examples

View source: R/ex2pdf.R

Description

Automatic generation of exercise sheets and exams in PDF format, inspired by the exams package.

Usage

1
2
3
ex2pdf(sheets, poolDir, templates, outDir = getwd(), names, n = 1,
  compiler = list(command = "latexmk", args = c("-pdf",
  "-interaction=batchmode")), clean = TRUE, ...)

Arguments

sheets

[list]
A list with the following mandatory entries:

  • exercises [list] with file names to look for in poolDir. This is done recursively. Don't give the absolute path or relative path, just the file name. You can omit the extension. If a list entry is a character vector of file names, they get sampled according to nsamp.

  • nsamp [integer] giving the number of exercises to sample, if the corresponding entry of exercises is a character. As most as long as exercises. Gets recycled if shorter.

Additional entries are available during brewing of the templates files. If the list entries are named, the names are appended to names to generate unique file names.

poolDir

[string]
Path of the directory storing the exercise files.

templates

[character]
Path of template files. Each file must follow the brew specifications. Each template will be brewed, knited and compiled into one single PDF.

outDir

[string]
Path of the output directory. Default is the current working directory.

names

[character]
Specifies the naming scheme of each template in the output directory.

n

[integer]
Specifies the number of copies to be generated per template. If n>1, the numer of copy is appended to the output file name.

compiler

[list]
Specifies the LaTeX compiler and its arguments. Must have the following entries:

  • command [string] name of the executable of the LaTeX compiler to be called.

  • args [character] vector of arguments passed to the LaTeX compiler.

clean

[character or flag]
If TRUE all files but PDF files in outDir are removed after compilation. If a character vector, only files with the given extensions are removed after compilation. If FALSE no clean up is done.

...

Any further arguments passed to the environment of brew. This is helpful to pass static elements such as e-mail adresses or semester identifier to all brew calls.

Details

Examples of templates are installed in systemfile("templates", package = "imbs)}. Examples of exercises and solutions are installed in \code{systemfile("templates", package = "imbs).

Value

Invisible character with path of generated PDF files.

Author(s)

Damian Gola, gola@imbs.uni-luebeck.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
## Not run: 
if(require(ggplot2)) {
sheets <- list(w1 = list(exercises = list("sum1", "sum2"), 
                         nsamp = c(1, 1),
                         date = "yyyy-mm-dd"),
               w2 = list(exercises = list(c("boxplot1", "regression1")),  
                         nsamp = 1,
                         date = "yyyy-mm-dd"))

ex2pdf(sheets = sheets,
       poolDir = system.file("pool", package = "imbs"),
       templates = c(system.file("templates/exercise.brew", package = "imbs"),
                     system.file("templates/solution.brew", package = "imbs")),
       outDir = file.path(getwd(), "ex2pdfTest"),
       names = c("Exercise", "Solution"),
       n = 2,
       compiler = list(command = "pdflatex",
                       args = c("-interaction=batchmode")),
       year = 2016,
       email = "mail@example.net")
 }

## End(Not run)

imbs-hl/imbs documentation built on Sept. 6, 2019, 11:05 p.m.