Eine Schnittstelle zur Latex-Compiler um Bilder aus Latex Code zu generieren.
Quick-check System
-
❏
convert --version
soll die Version von ImageMagick ausgeben. -
❏
xelatex --version
soll die Version von TexLive ausgeben. -
❏ TexLive ist so eingestellet, dass
\write18
partial erlaubt ist. -
❏ Das Latex-Paket
circdia
ist installiert. -
❏ Einstellung in Tomcat um Java AWT auch in Server Modus zu nutzen.
Installation von TexLive
-
TL soll mit
schema-full
installiert werden. -
Quickcheck: Kopieren den unterstehenden Code in
texmf.conf
% Enable system commands via \write18{...}. When enabled fully (set to
% t), obviously insecure. When enabled partially (set to p), only the
% commands listed in shell_escape_commands are allowed. Although this
% is not fully secure either, it is much better, and so useful that we
% enable it for everything but bare tex.
shell_escape = p
% No spaces in this command list.
%
% The programs listed here are as safe as any we know: they either do
% not write any output files, respect openout_any, or have hard-coded
% restrictions similar to or higher than openout_any=p. They also have
% no features to invoke arbitrary other programs, and no known
% exploitable bugs. All to the best of our knowledge. They also have
% practical use for being called from TeX.
%
shell_escape_commands = \
bibtex,bibtex8,biber,\
extractbb,\
gregorio,\
kpsewhich,\
makeindex,xindy\
repstopdf,\
texosquery-jre8,\
convert,convert-im6,\
uname
Installation von Latex-Paket circdia
-
Kopieren den Ordner
circdia
aus dem Ordnersrc/main/latex
in${HOME}/texmf/tex/latex
wobei ${HOME}
das Home-Verzeichnis von dem Nutzer, unter dessen Name die MathCoach-Web Anwendung läuft.cd src/main/latex cp -r circdia ${HOME}/texmf/tex/latex
-
Den Befehl
texhash ${HOME}/texmf/
aufrufen
Installation von Image Magick
Unter Ubuntu soll das Paket bereits installiert sein. Wenn nicht kann man mit
sudo apt install imagemagick
das Paket installieren.
Java AWT Einstellung
Füget in $CATALINA_BASE/setenv.sh
folgenden Code hinzu:
export CATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=true"
Anhang
Configure latex
Determine texmf.cnf
$ kpsewhich -a texmf.cnf
/opt/texlive/2017/texmf.cnf
/opt/texlive/2017/texmf-dist/web2c/texmf.cnf
Configure
-
Open the first output entry, eg.
/opt/texlive/2018/texmf.cnf
, you should see something like
% (Public domain.)
% This texmf.cnf file should contain only your personal changes from the
% original texmf.cnf (for example, as chosen in the installer).
%
% That is, if you need to make changes to texmf.cnf, put your custom
% settings in this file, which is .../texlive/YYYY/texmf.cnf, rather than
% the distributed file (which is .../texlive/YYYY/texmf-dist/web2c/texmf.cnf).
% And include *only* your changed values, not a copy of the whole thing!
%
-
Extend the opened file with the following code:
% Enable system commands via \write18{...}. When enabled fully (set to
% t), obviously insecure. When enabled partially (set to p), only the
% commands listed in shell_escape_commands are allowed. Although this
% is not fully secure either, it is much better, and so useful that we
% enable it for everything but bare tex.
shell_escape = p
% No spaces in this command list.
%
% The programs listed here are as safe as any we know: they either do
% not write any output files, respect openout_any, or have hard-coded
% restrictions similar to or higher than openout_any=p. They also have
% no features to invoke arbitrary other programs, and no known
% exploitable bugs. All to the best of our knowledge. They also have
% practical use for being called from TeX.
%
shell_escape_commands = \
bibtex,bibtex8,biber,\
extractbb,\
gregorio,\
kpsewhich,\
makeindex,xindy\
repstopdf,\
texosquery-jre8,\
convert,convert-im6,\
uname
Affect: All Tex-Compiler (tex
, xetex
, pdflatex
, xelatex
, ect.) are permitted to call all commands above.
-
Save the above file and try to compile the file
tex/standalone-tikz.tex
with
cd tex
xelatex standalone-tikz.tex
You should see a generated file standalone-tikz.png
and a Warning in console like
Class standalone Warning: Conversion failed! Please ensure that shell escape
(standalone) is enabled (e.g. use '-shell-escape').
Compile the file again. The PNG File standalone-tikz.png
must be generated.
In some case ImageMagick is configured, that it does not have authority to access PDF / PS files. You will get error like:
convert: not authorized `TexPicture-D1DCB88201027DC556E52715EB3E16820C6E0F39095242863F234B9FD3CD66F2.pdf' @ error/constitute.c/ReadImage/412.
convert: no images defined `TexPicture-D1DCB88201027DC556E52715EB3E16820C6E0F39095242863F234B9FD3CD66F2.png' @ error/convert.c/ConvertImageCommand/3210.
system returned with code 256
In such situation
one can change the Policy of ImageMagick in the file /etc/ImageMagick-6/policy.xml
. Change the line
<policy domain="coder" rights="none" pattern="PDF" />
to
<policy domain="coder" rights="read|write" pattern="PDF" />
should allow ImageMagick to access PDF files.