Moodlle 包:includegraphics 和 tikzpicture 存在问题

Moodlle 包:includegraphics 和 tikzpicture 存在问题

就我而言,由于 moodle 包的原因,使用 includegraphics 命令和 tikzpicture 环境时,XML 文件中仍存在两个问题。它们都无法显示在 moodle 站点上。如何处理?

我获得了一些线索,如下面的文件所述。

\documentclass[12pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage{fouriernc,sourceserifpro}
\usepackage[draft]{moodle}
\usepackage{graphicx}
\usepackage{xpatch}
\makeatletter
\def\graphicspath#1{\def\Ginput@path{#1}\edef\moodleimgpath{\@firstofone#1}}

\xpatchcmd{\moodle@includegraphics@int@int}%
{\openssl\otherspace enc -base64 -in #2.jpg -out #2.enc}%
{\openssl\otherspace enc -base64 -in \moodleimgpath#2.jpg -out #2.enc}%
{\typeout{patch ok}}%
{\typeout{patch failed}}
\makeatother

\graphicspath{{./gambar/}}
\pagestyle{empty}
\usepackage{tikz}
\newsavebox\picbox
\begin{lrbox}{\picbox}%
\begin{tikzpicture}
       \draw[thick] (0,0) circle(1cm);
\end{tikzpicture}
\end{lrbox}
\begin{document}

\begin{quiz}{Pelatihan 1}
  \begin{multi}[shuffle=true, points=1]{{\em Corona Virus Disease}-19}
    Soal ini berbentuk pilihan berganda.

    \includegraphics[width=6cm]{covid-19}

  \item* 1
  \item 2
\end{multi}

\begin{numerical}[points=2]{Tentang soal nomor 2}
Soal ini berbentuk numerik dan opsinya berupa {\em itemize}.
\item 11
\end{numerical}

\begin{shortanswer}[case sensitive=true]{Tentang soal nomor 3}
Soal ini berbentuk {\em case sensitive} dan opsinya berupa {\em itemize}.
\item Benar
\item[fraction=0, feedback={Bukan, Bro!}] Salah
\item{fraction=50} Bukan jawaban
\end{shortanswer}

\begin{multi}[points=3]{Turunan pertama}
Apa turunan pertama dari $x^3$?
\item $\frac{1}{4} x^4+C$
\item* $3x^2$
\end{multi}

\begin{multi}{Gambar}
Apakah ini sebuah lingkaran?

\usebox\picbox

      \item* Ya
      \item Bukan
    \end{multi}
\end{quiz}

\end{document}

我从这里

答案1

嗯---这是我的经验(请注意,我完全不懂测试所用的语言。所以我对此不承担责任)(下次最好使用英语!):

  1. moodle.sty修补程序tikz,但我真的从未设法让它工作。所以我通常使用外部独立文件来生成图像,然后将其包含在内includegraphics

  2. 此外,图形路径很棘手 --- 尽管有一个补丁在起作用,但我更喜欢简单地将图像添加到同一个目录中,然后忘记它。

  3. 您正在修补graphicx(我不知道为什么),并且使用\em至少 30 年来已被弃用的方法...;-) --- 必须使用\emph{text}正确的方法。

  4. 您对 moodle include 命令应用的补丁失败:在日志中您有:

    ...
    补丁失败
    (./testm.aux)
    *几何* 驱动程序:自动检测
    ...
    

因此,这里的代码是:

\documentclass[12pt]{article}
\usepackage[margin=3cm]{geometry}
\usepackage[]{moodle}
\usepackage{graphicx}

\begin{document}

\begin{quiz}{Pelatihan 1}
  % You can't use commands in the test name!
  \begin{multi}[shuffle=true, points=1]{Corona Virus Disease-19}
    Soal ini berbentuk pilihan berganda.

    \includegraphics[width=6cm]{covid-19.jpg}

  \item* 1
  \item 2
\end{multi}

\begin{numerical}[points=2]{Tentang soal nomor 2}

Soal ini berbentuk numerik dan opsinya berupa \emph{itemize}.
\item 11
\end{numerical}

\begin{shortanswer}[case sensitive=true]{Tentang soal nomor 3}
Soal ini berbentuk \emph{case sensitive} dan opsinya berupa \emph{itemize}.
\item Benar
\item[fraction=0, feedback={Bukan, Bro!}] Salah
\item{fraction=50} Bukan jawaban
\end{shortanswer}

\begin{multi}[points=3]{Turunan pertama}
Apa turunan pertama dari $x^3$?
\item $\frac{1}{4} x^4+C$
\item* $3x^2$
\end{multi}

\begin{multi}{Gambar}
Apakah ini sebuah lingkaran?

      \item* Ya
      \item Bukan
    \end{multi}
\end{quiz}

\end{document}

如果文件covid-19.jpg位于同一目录中并使用 进行编译pdflatex -shell-escape testm.sty,则可以正常工作。

在此处输入图片描述

...第一个:

在此处输入图片描述

如果在包含图像时遇到问题,请检查日志文件(或输出)中的转换是否正常;就我而言,它是:

...
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd)
moodle.sty: Processing \includegraphics[width=6cm]{covid-19.jpg} for HTML...
moodle.sty: Converting 'covid-19.jpg' to PNG...
moodle.sty: Converting 'covid-19.jpg.png' to base64...
moodle.sty: Reading base64 file 'covid-19.jpg.enc'...
moodle.sty: <IMG> tag inserted.
...

为了帮助调试图形问题,您可以下载此文件为moodleshow.tex然后添加

\input{moodleshow.tex}

在您的序言中(加载moodle包后),它将在日志文件中打印附加信息,如下所示:

moodle.sty: Processing \includegraphics[width=6cm]{covid-19.jpg} for HTML...
moodle.sty: Converting 'covid-19.jpg' to PNG...
command is: convert covid-19.jpg -resize 472 covid-19.jpg.png
command is: openssl enc -base64 -in covid-19.jpg.png -out covid-19.jpg.enc
command is: openssl enc -base64 -in covid-19.jpg.png -out covid-19.jpg.enc
moodle.sty: Reading base64 file 'covid-19.jpg.enc'...
moodle.sty: <IMG> tag inserted.

tikz关于圆形图像,您可以使用和类生成 PDF standalone,然后将其包含在内\includegrahics{}

相关内容