在Rnw内使用同位素乳胶包装(r-检查) [英] Use isotope latex-package inside Rnw (r-exams)

查看:42
本文介绍了在Rnw内使用同位素乳胶包装(r-检查)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在 .Rnw 中加载并使用同位素包文件:

I want to load and use isotope package in my .Rnw file:

\exname{foo}
\extype{schoice}
\exsolution{0001}
\usepackage{isotope}
\begin{question}
  Foo \isotope[A][Z]{H}\ bar
  \begin{answerlist}
    \item a
    \item b
    \item c
    \item d
  \end{answerlist}
\end{question}

但是,当我将其呈现为Moodle的XML( exams2moodle )时, \ isotope 消失并且仅显示 Foo bar .我正在使用MathML渲染.

But when I render it into Moodle's XML (exams2moodle) the \isotope disappear and appears only Foo bar. I'm using MathML rendering.

如何正确加载和使用?

推荐答案

这个简短的答案是:我无法使用MathML或MathJax渲染 \ isotope 命令(我知道).另请参阅以下讨论:如何在R/中使用LaTeX包考试?

This short answer is: There is no way (that I know of) of rendering the \isotope command using either MathML or MathJax. See also this discussion: How to use a LaTeX package with R/exams?

有两种可能的解决方法:

There are two possible workarounds:

照常使用pdfLaTeX编译 \ isotope 命令,提取图像(例如,在SVG矢量图形中),然后将其嵌入到练习中.使用 tex2image()函数可以方便地完成所有这些操作.

Compile the \isotope command using pdfLaTeX as usual, extract the image (e.g., in a SVG vector graphic), and embed it into the exercise is. All this can be done conveniently with the tex2image() function.

优点是您可以使用习惯的 isotope 包.但是,有许多缺点:渲染速度很慢,尤其是在需要许多此类图像的情况下.图形的缩放比例可能与文本的缩放比例不匹配,尤其是在放大HTML时.您需要的图形类型将取决于输出的类型(HTML与PDF)等.

The advantage is that you can use the isotope package that you are used to. However, there is a number of disadvantages: The rendering is rather slow, especially if you need many such images.The scaling of the graphic might not match the scaling of the text, especially when zooming into the HTML. The kind of graphic you need will depend on the kind of output (HTML vs. PDF) etc.

使用标准LaTeX命令模拟输出,而不是使用专用软件包.在这种情况下,使用 amsmath 中的 \ sideset 命令是一种选择,因为MathJax支持 amsmath 包(但MathML转换器不支持)).缺点:LaTeX代码比较麻烦.优点:非常快,可以在HTML中缩放,也可以在PDF中工作.因此,我建议选择方案2.

Rather than using a specialized package, mimic the output using standard LaTeX commands. In this case using the \sideset command from amsmath would be one option because the amsmath package is supported by MathJax (but not in the MathML converters). Disadvantage: The LaTeX code is slightly more cumbersome. Advantages: Very fast, can be scaled in the HTML, works also in PDF. Hence, I would recommend Option 2.

下面是 foo.Rnw 文件的改编代码.可以通过以下方式将其呈现为HTML:

Below is the adapted code of your foo.Rnw file. This can be rendered into HTML via:

exams2html("foo.Rnw", converter = "pandoc-mathjax")

这与当前版本的R/exams在 exams2moodle()中使用的转换器相同.

This is the same converter that current versions of R/exams use in exams2moodle() as well.

<<echo=FALSE, results=hide>>=
tex2image("\\isotope[A][Z]{H}", packages = "isotope",
  name = "iso_AZH", format = "svg", dir = ".")
@

\begin{question}
Option 1: \includegraphics{iso_AZH.svg}

Option 2: $\sideset{_Z^A}{}H$
\begin{answerlist}
  \item a
  \item b
  \item c
  \item d
\end{answerlist}
\end{question}

\exname{foo}
\extype{schoice}
\exsolution{0001}

这篇关于在Rnw内使用同位素乳胶包装(r-检查)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆