Problem notation Tex

Problem notation Tex

by jeanjean moulin -
Number of replies: 5

Hello,

Some teachers would like to use tex notation on our Moodle platform to make it easier to create their courses, as they already use LaTeX outside of Moodle.
However, the preamble of LaTeX doesn't seem to be taken into account, the problem seems to come from /usr/bin/convert but we can't find the cause of the problem.
I installed texlive-full and imagemagick. All paths are correct.

Here is our preamble:

\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{stmaryrd}
\usepackage{amssymb}
%\usepackage{latexsym}
%\RequirePackage{amsmath,amssymb,latexsym}
\newcommand{\N}{\mathbb{N}}


Using the Tex Filter Debugger, we get the following results for each test :
1 - 

DB cache_filters entry for f(x)=\int_{-\infty}^x~e^{-t^2}dt not found

3 -

sh: 1: /var/www/moodle/filter/tex/mimetex.linux: not found
The shell command
"/var/www/moodle/filter/tex/mimetex.linux" -e "/var/www/moodledata/filter/tex/9608176195573c30c6beb3cf078fdf66.gif" -- '\Large f(x)=\int_{-\infty}^x~e^{-t^2}dt'
returned status = 127
File size of mimetex executable /var/www/moodle/filter/tex/mimetex.linux is 1317676
The file permissions are: 100755
The md5 checksum of the file is be9326dfd98c19c55b37beb1acc132c7
Image not found!
No text output available

4-

Error creating image, see command execution output for more details. 

5-

Checking executables

latex executable (/usr/bin/latex) is readable
dvips executable (/usr/bin/dvips) is readable
convert executable (/usr/bin/convert) is readable
dvisvgm executable (/usr/bin/dvisvgm) is readable

base filename for expression is '9608176195573c30c6beb3cf078fdf66'

Processing TeX expression:

f(x)=\int_{-\infty}^x~e^{-t^2}dt
$ '/usr/bin/latex' --interaction=nonstopmode --halt-on-error /var/www/moodledata/temp/latex/9608176195573c30c6beb3cf078fdf66.tex
OUTPUT: This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2019/dev/Debian) (preloaded format=latex)
 restricted \write18 enabled.
entering extended mode
(/var/www/moodledata/temp/latex/9608176195573c30c6beb3cf078fdf66.tex
LaTeX2e <2018-12-01>
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size12.clo))
(/usr/share/texlive/texmf-dist/tex/latex/base/inputenc.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amsfonts.sty)
(/usr/share/texlive/texmf-dist/tex/latex/stmaryrd/stmaryrd.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/amssymb.sty)
(./9608176195573c30c6beb3cf078fdf66.aux)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/share/texlive/texmf-dist/tex/latex/amsfonts/umsb.fd)
(/usr/share/texlive/texmf-dist/tex/latex/stmaryrd/Ustmry.fd) [1]
(./9608176195573c30c6beb3cf078fdf66.aux) )
Output written on 9608176195573c30c6beb3cf078fdf66.dvi (1 page, 496 bytes).
Transcript written on 9608176195573c30c6beb3cf078fdf66.log.
RETURN CODE: 0
$ '/usr/bin/dvips' -E /var/www/moodledata/temp/latex/9608176195573c30c6beb3cf078fdf66.dvi -o /var/www/moodledata/temp/latex/9608176195573c30c6beb3cf078fdf66.ps
OUTPUT: 
RETURN CODE: 0
$ '/usr/bin/convert' -density 240 -trim /var/www/moodledata/temp/latex/9608176195573c30c6beb3cf078fdf66.ps /var/www/moodledata/temp/latex/9608176195573c30c6beb3cf078fdf66.gif 
OUTPUT: 
RETURN CODE: 1



So the problem seems to come from convert ... (/etc/ImageMagick-6/policy.xml seems to be well set up though) . And in similar cases in 2004-2006, it was related to safe_mode=on, but this has become obsolete nowadays...

Does anyone know the cause of the problem and how to solve it?

Cordially,
Arnaud Taburet

Average of ratings: -
In reply to jeanjean moulin

Re: Problem notation Tex

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

What version of Moodle is this?

Do you have the MathJax filter enabled? This could be overwriting any images the TeX notation filter is generating.

That convert error suggests there's a policy in policy.xml preventing the operation. The "not allowed by security policy" message appears to be external to Moodle so you may get a more informed answer from the ImageMagick community. But for reference here's what I get on my CentOS 7 system (ImageMagick-6.9.10.68-3.el7.x86_64):

$ '/usr/bin/convert' -density 240 -trim /var/www/m382/moodledata/temp/latex/9608176195573c30c6beb3cf078fdf66.ps /var/www/m382/moodledata/temp/latex/9608176195573c30c6beb3cf078fdf66.gif 
OUTPUT:
RETURN CODE: 0
The command identify -list policy might list policies but I'm not an ImageMagick expert.
Average of ratings: Useful (1)
In reply to Leon Stringer

Re: Problem notation Tex

by jeanjean moulin -
Thank you for your reply.

So the version of the Moodle is 3.8. Yes, Mathjax is disable.

I found the solution for convert : The issue was in policy.xml. I had to edited /etc/ImageMagick.../policy.xml :
change this line :
#           <policy domain="coder" rights="none" pattern="PS" />
to:
#           <policy domain="coder" rights="read|write" pattern="PS" />

and add :  #  <policy domain="coder" rights="read|write" pattern="LABEL" />
Average of ratings: Useful (1)
In reply to jeanjean moulin

Re: Problem notation Tex

by Ken Task -
Picture of Particularly helpful Moodlers

@Leon ... now it's my turn ... pardon intrusion ... happended to be working on an issue for a math teacher just yesterday ...

OP ... not really an answer but maybe something that will help ... see all the commands used but can't really see what those generate, so ... there is a hidden tool not linked in admin menus:

https://yoursite/filter/tex/texdebug.php

Did discover on a CentOS 7 server the mimetype.linux script was 32 bit and required some old 32 bit libraries installed to function.

And ... if CentOS 7 ... did you check for seLinux complaints or if you are running something like mod_security issues seen in it's logs?

Don't teach math myself ... am doing good to balance my checkbook! :|

'SoS', Ken

In reply to jeanjean moulin

Re: Problem notation Tex

by jeanjean moulin -
So I found the solution for convert

Now I have a display using Tex but the only output format I can use is PNG (GIF looks horrible and SVG don't display any image...)

Even with PNG, the display looks very bad and it seems like there is no solution for that       (If anyone has a solution, please share it)
it's sad to have this resultat after spending some time on it....

I found a FAQ about Mathematics tools (TeX, Mathjax, Wiris, etc...), read it very interesting : https://docs.moodle.org/39/en/Mathematics_tools_FAQ
The last question is about poor quality display (image below)

In conclusion, we will give up on TeX and just use Mathjax instead...

Cordially,
Arnaud Taburet
In reply to jeanjean moulin

Re: Problem notation Tex

by Leon Stringer -
Picture of Core developers Picture of Particularly helpful Moodlers

On my site using the TeX notation filter (MathJax disabled) with PNG I get:

Some TeX mathematical symbols

which looks okay to me. All my other settings are default. Are your formulas displayed like this? Or worse?

Are there any TeX sequences you want me to try or anything I can share about my config? I have pdfTeX 3.14159265-2.6-1.40.21 (TeX Live 2020) on CentOS 7 with Moodle 3.8.