moodle.sty 插入图形时出现问题

moodle.sty 插入图形时出现问题

我正在尝试制作一个 moodle 测验并包含一个 png 图像。请参阅我的 latex 文档。我正在使用 PDFLaTeX 进行编译。xml 不包含图像。

\documentclass[10pt]{article}
\usepackage[section]{moodle}
\usepackage{graphicx}



\begin{document}
\begin{quiz}{Use of English part 2}
    \begin{cloze}{A bad Habit}
        \includegraphics[width=6in]{badHabit.png}
        \begin{enumerate}
        \item \begin{shortanswer}
                \item although
                \end{shortanswer}
        \item \begin{shortanswer}
                \item in
                \end{shortanswer}
        \item \begin{shortanswer}
                \item any
                \end{shortanswer}
        \item \begin{shortanswer}
                \item deal
                \end{shortanswer}
        \item \begin{shortanswer}
                \item at
                \end{shortanswer}
        \item \begin{shortanswer}[usecase]
                \item Whatever
                \end{shortanswer}
        \item \begin{shortanswer}
                \item it's
                \end{shortanswer}
        \item \begin{shortanswer}[usecase]
                \item Apart
                \end{shortanswer}
        \end{enumerate}
    \end{cloze}
\end{quiz}
\end{document}

我的错误是:

在此处输入图片描述

我读过其他有类似问题的帖子。我尝试在 texmaker 中将 --shell-escape=true 包含到 PDFLaTeX 中,但编译时出现以下错误: 在此处输入图片描述

我是 LaTeX 新手,所以请多多包涵。我按照文档说明安装了 ghostscript 和 imagemagick。我无法运行 optipng.exe(32 位,什么都没发生),所以我没有安装它。希望有人能告诉我哪里出了问题。谢谢!

编辑1:检查日志文件后,我发现该进程停止了。

moodle.sty: Processing \includegraphics[width=6in]{badHabit.png} for HTML...
<<extension .png(PNG) identified>>
moodle.sty: Converting 'badHabit.png' to base64...
runsystem(certutil -encode "badHabit.png" tmp.b64 && findstr /vbc:"---" tmp.b64
 > "badHabit.enc" && del tmp.b64)...disabled (restricted).


! Package moodle Error: Base64 conversion failed.

See the moodle package documentation for explanation.
Type  H <return>  for immediate help.
 ...   

编辑 2:现在似乎添加了 --shell-escape 标志就可以转换图像了。我现在遇到了有关 TeX 容量超出的错误。

(C:\Users\AdamM\AppData\Local\Programs\MiKTeX\tex/latex/amsfonts\umsb.fd
File: umsb.fd 2013/01/14 v3.01 AMS symbols B
)
moodle.sty: Processing \includegraphics[width=6in]{badHabit.png} for HTML...
<<extension .png(PNG) identified>>
moodle.sty: Converting 'badHabit.png' to base64...
runsystem(certutil -encode "badHabit.png" tmp.b64 && findstr /vbc:"---" tmp.b64
 > "badHabit.enc" && del tmp.b64)...executed.

moodle.sty: Reading base64 file 'badHabit.enc'...
runsystem(del "badHabit.enc")...executed.

Runaway definition?
->
! TeX capacity exceeded, sorry [main memory size=3000000].
\g@addto@macro ...fter {#1#2}\xdef #1{\the \toks@ 
                                                  }\endgroup 
l.37    \end{cloze}
                 
If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

 
Here is how much of TeX's memory you used:
 4461 strings out of 478582
 76562 string characters out of 2844344
 3000001 words of memory out of 3000000
 22585 multiletter control sequences out of 15000+600000
 472686 words of font info for 42 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 74i,11n,77p,588b,536s stack positions out of 10000i,1000n,20000p,200000b,80000s
!  ==> Fatal error occurred, no output PDF file produced!

答案1

图像转换过程中的某些步骤不起作用。您可以通过查看文件来找出是哪一个步骤.log;您应该会发现类似以下内容:

moodle.sty: Processing \includegraphics[width=6in]{example-image-c} for HTML...

moodle.sty: Converting 'example-image-c' to PNG...
runsystem(convert -colorspace RGB "example-image-c.pdf" -resize 618 "example-im
age-c.png")...executed.

moodle.sty: Optimizing 'example-image-c.png'...
runsystem(optipng -clobber -strip all -quiet "example-image-c.png")...executed.

moodle.sty: Converting 'example-image-c.png' to base64...
runsystem(base64 "example-image-c.png" > "example-image-c.enc")...executed.

moodle.sty: Reading base64 file 'example-image-c.enc'...
runsystem(rm -f "example-image-c.enc" "example-image-c.png")...executed.

如果您使用的是 Windows,那么执行转换的程序base64就是所谓的certutil(是的,它应该在手册中提到,这基本上是一个文档错误)。

请注意需要--shell-escape旗帜。

声明/检查版本也很重要;您.log也可以在文件中找到它:

(/home/romano/texlive2021/texmf-dist/tex/latex/moodle/moodle.sty
Package: moodle 2021/02/07 v0.9 Moodle quiz XML generation

相关内容