R/ The包使用其函数TikZ支持包含include_tikz()图形,例如,如随包附带的自动机和逻辑练习所示。
在让include_tikz()完成这些练习(请参阅:为什么TikZ图形是用exams2pdf呈现的,而不是用exams2moodle呈现的?)之后,我尝试创建自己的练习。然而,到目前为止,这还不起作用。我的代码是:
```{r datos1, echo = FALSE, results = "hide"}选项(tinytex.verbose= TRUE)
选项(scipen=999)
knitr::opts_chunk$set(echo =真)
##opts_chunk$set(fig.cap="")
图书馆(考试)
图书馆(魔法)
问题<-解<-解释<-空
问题1<-粘贴(“图1.")
解1<-真
解释1<-“。
问题2<-粘贴(“图2.")
解决方案2<-FALSE
说明2<-“。
问题3<-粘贴(“图3.")
解决方案3<-FALSE
解释3<-“。
问题4<-粘贴(“图4.")
解决方案4<-FALSE
解释4<-“。
orden<-样本(1:4)
问题<-问题
解决方案<-解决方案
解释<-解释
梯度01<-‘
确定颜色{uuuuuu}{rgb}{0.26,0.26,0.26};
定义颜色{zzttqq}{rgb}{0.6,0.2,0};
确定颜色{ududff}{rgb}{0.30,0.30,1};
cap=round,join=round,>=triangle 45,x=1cm,y=1cm
夹子(-0.1,-0.1)矩形(5,5);
填充行width=2pt,color=zzttqq,fill=zzttqq,fill opacity=0.10 -- (4.68,-0.02) --
(4.7,4.66) -- (0.02,4.68) -循环;
绘制(0.9,3.80) nodeanchor=north西部{\textbf{49};
绘制(3.44,3.80) nodeanchor=north西部{\textbf{12}};
绘制(2.22,1.74) nodeanchor=north西部{\textbf{14};
绘制(2.22,3.00) nodeanchor=north西部{\textbf{5};
绘制(2.22,3.96) nodeanchor=north西部{\textbf{6}};
绘制(1.40,2.53) nodeanchor=north西部{\textbf{8}};
绘制(3.00,2.53) nodeanchor=north西部{\textbf{9}};
绘制(3.85,1.39) nodeanchor=north西部{\textbf{};
绘制(0.35,4.57) nodeanchor=north西{\textbf{DH};
绘制(3.97,4.57) nodeanchor=north西部{\textbf{CA};
绘制(2.31,0.72) nodeanchor=north西部{\textbf{R};
绘制线width=2pt圆(1.3cm);
绘制线width=2pt圆(1.3cm);
绘制线width=2pt圆(1.3cm);
绘制line width=2pt,color=zzttqq- (4.68,-0.02);
绘制line width=2pt,color=zzttqq- (4.7,4.66);
绘制line width=2pt,color=zzttqq-- (0.02,4.68);
绘制line width=2pt,color=zzttqq- (0,0);
开始{脚本大小}
绘制fill=ududff圆(2.5pt);
绘制fill=ududff圆(2.5pt);
绘制fill=uuuuuu圆(2.5pt);
绘制fill=uuuuuu圆(2.5pt);
结束{scriptsize}
结束{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(“箭头”))
```{r questionlist, echo = FALSE, results = "asis"}图书馆(考试)
答案列表(问题,标记=“标记”)
在其他练习中,我已经包含了用TikZ创建的这个映像的源代码,但是在R块之外(从\begin{tikzpicture}到\end{tikzpicture}),所以它可以与exams2pdf() (屏幕截图)一起工作。但我无法让它与exams2moodle()一起工作。
发布于 2021-05-21 16:55:22
解决了!
感谢阿奇姆·齐莱伊斯不懈的伴奏。我分享修正后的代码:
graf01<-c("\\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}")那么调用TicZ的代码块是:
```{r, echo = FALSE, results = "asis"}include_tikz(graf01,name = "graf",markup = "markdown",format = typ,library =
C(“箭头”),packages =“booktab”,宽度= "5cm")
format = typ部分在代码的开头声明:
typ <- match_exams_device()再次谢谢你,阿金。他的工作值得赞扬。希望有一天我能在这个社区里做出和你们一样伟大的贡献。祝福!
https://stackoverflow.com/questions/67630203
复制相似问题