R/exams 包支持使用其功能包含 TikZ 图形include_tikz()
,例如,如图所示自动机 and logic练习随包装一起提供。
得到后include_tikz()
进行这些练习(参见:为什么 TikZ 图形是用 exams2pdf 渲染的,而不是用 exams2moodle 渲染的?)我尝试创建自己的练习。然而,到目前为止这还不起作用。我的代码是:
```{r datos1, echo = FALSE, results = "hide"}
options(tinytex.verbose = TRUE)
options(scipen=999)
knitr::opts_chunk$set(echo = TRUE)
##opts_chunk$set(fig.cap="")
library(exams)
library(magick)
questions<-solutions<-explanations<-NULL
questions[1]<-paste("Graph 1.")
solutions[1]<-TRUE
explanations[1]<-"."
questions[2]<-paste("Graph 2.")
solutions[2]<-FALSE
explanations[2]<-"."
questions[3]<-paste("Graph 3.")
solutions[3]<-FALSE
explanations[3]<-"."
questions[4]<-paste("Graph 4.")
solutions[4]<-FALSE
explanations[4]<-"."
orden<-sample(1:4)
questions<-questions[orden]
solutions<-solutions[orden]
explanations<-explanations[orden]
graf01<-'
\\definecolor{uuuuuu}{rgb}{0.26,0.26,0.26};
\\definecolor{zzttqq}{rgb}{0.6,0.2,0};
\\definecolor{ududff}{rgb}{0.30,0.30,1};
\\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=1cm,y=1cm]
\\clip(-0.1,-0.1) rectangle (5,5);
\\fill[line width=2pt,color=zzttqq,fill=zzttqq,fill opacity=0.10] (0,0) -- (4.68,-0.02) --
(4.7,4.66) -- (0.02,4.68) -- cycle;
\\draw (0.99,3.80) node[anchor=north west] {\\textbf{49}};
\\draw (3.44,3.80) node[anchor=north west] {\\textbf{12}};
\\draw (2.22,1.74) node[anchor=north west] {\\textbf{14}};
\\draw (2.22,3.00) node[anchor=north west] {\\textbf{5}};
\\draw (2.22,3.96) node[anchor=north west] {\\textbf{6}};
\\draw (1.40,2.53) node[anchor=north west] {\\textbf{8}};
\\draw (3.00,2.53) node[anchor=north west] {\\textbf{9}};
\\draw (3.85,1.39) node[anchor=north west] {\\textbf{}};
\\draw (0.35,4.57) node[anchor=north west] {\\textbf{DH}};
\\draw (3.97,4.57) node[anchor=north west] {\\textbf{CA}};
\\draw (2.31,0.72) node[anchor=north west] {\\textbf{R}};
\\draw [line width=2pt] (1.76,3.08) circle (1.3cm);
\\draw [line width=2pt] (3.05,3.13) circle (1.3cm);
\\draw [line width=2pt] (2.45,1.98) circle (1.3cm);
\\draw [line width=2pt,color=zzttqq] (0,0)-- (4.68,-0.02);
\\draw [line width=2pt,color=zzttqq] (4.68,-0.02)-- (4.7,4.66);
\\draw [line width=2pt,color=zzttqq] (4.7,4.66)-- (0.02,4.68);
\\draw [line width=2pt,color=zzttqq] (0.02,4.68)-- (0,0);
\\begin{scriptsize}
\\draw [fill=ududff] (0,0) circle (2.5pt);
\\draw [fill=ududff] (4.68,-0.02) circle (2.5pt);
\\draw [fill=uuuuuu] (4.7,4.66) circle (2.5pt);
\\draw [fill=uuuuuu] (0.02,4.68) circle (2.5pt);
\\end{scriptsize}
\\end{tikzpicture}
'
```
Question
========
An auto dealer sold 53 cars in a month; 33 of them had hydraulic steering (DH); 21 were
automatic gearboxes (CA); and 38 had radius (R); 4 had hydraulic steering, automatic gears
and radio; 3 had power steering and automatic shifts, but they had no radio; 13 had
automatic gears and radio, but did not have hydraulics and, 15 had hydraulics and radio, but
did not have automatic gears.
The graph that represents the information of the sale in the agency is
Graph 1:
```{r, echo = FALSE, results = "asis"}
include_tikz(graf01, name = "graf01", markup = "markdown",library = c("arrows"))
```
```{r questionlist, echo = FALSE, results = "asis"}
library(exams)
answerlist(questions, markup = "markdown")
```
在其他练习中,我包含了在中创建的该图像的源代码TikZ
,但在 R 块之外(来自\begin{tikzpicture}
to \end{tikzpicture}
)以便它可以与exams2pdf()
(截屏)。但我无法让它工作exams2moodle()
.