I’m sure I have carefully read the “LaTeX” chapter in “Anki-Manual”. But Anki was crashed without any error message when I use the “chemfig” package of LaTeX.
The LaTeX header is very simple which I only added “\usepackage{chemfig}” code like the handbook shown.
Here is my full header code:
But Anki was crashed, or more accurately it had no responding when I want to see the results by whatever clicking “preview” button or clicking “Study Now” button.
So I have to abort this progress by using “Windows Task Manager”
My Anki version is 2.1.44, and my “TeX Live” is the latest version.
Does anyone know what is going wrong? Thanks !
ps:Please ignore my grammar mistakes, I am not a English native speaker.
I’m grateful for your reply!
I guess I may have found the key of the mistakes with your help.
I found that the problem isn’t in the package I had used, it is the renderer mistake.
I checked the “anki_temp” folder and found that “tmp.dvi” file couldn’t be rendered correctly, So I changed LaTeX header:
\documentclass[UTF-8]{ctexart}
The good news is Anki did not crash when I tryed to preview.
But bad news is the chemical formula didn’t render correctly.
I realized that anki used “LaTeX” to render and “dvipng” to convert “.dvi” file into “.png” file.
That means I should use “XeLaTex” instead of “LaTex” and use “dvipdfmx” instead of “dvipng”, but I was confused by the commands in dvipdfmx’s Options.
Usage: dvipdfmx [OPTION]... [DVIFILE[.dvi|.xdv]]
dvipdfmx --extractbb|--xbb|--ebb [OPTION]... Be "extractbb"
dvipdfmx --help|--showpaper|--version
Convert DVI or XDV input to PDF; defaults given below.
Options:
-c Ignore color specials (for B&W printing)
--dvipdfm Enable DVIPDFM emulation mode
-d number Set PDF decimal digits (0-5) [3]
-f filename Load additional font map filename[.map]
-g dimension Annotation "grow" amount [0.0in]
-h | --help Show this help message and exit
-l Landscape mode
-m number Set additional magnification [1.0]
--mvorigin Translate the origin for MP inclusion
-o filename Set output file name, "-" for stdout [DVIFILE.pdf]
-p papersize Set papersize [a4]
-q Be quiet
-r resolution Set resolution (in DPI) for raster fonts [600]
-s pages Select page ranges [all pages]
--showpaper Show available paper formats and exit
-t Embed thumbnail images of PNG format (DVIFILE.pageno, pageno=int)
--version Output version information and exit
-v Be verbose
-vv Be more verbose
--kpathsea-debug number Set kpathsea debugging flags [0]
-x dimension Set horizontal offset [1.0in]
-y dimension Set vertical offset [1.0in]
-z number Set zlib compression level (0-9) [9]
-C number Specify miscellaneous option flags [0]:
0x0001 reserved
0x0002 Use semi-transparent filling for tpic shading command,
instead of opaque gray color; requires PDF 1.4.
0x0004 Treat all CIDFont as fixed-pitch font.
0x0008 Do not replace duplicate fontmap entries.
0x0010 Do not optimize PDF destinations.
0x0020 Do not use predictor filter for Flate compression.
0x0040 Do not use object stream.
Positive values are always ORed with previously given flags.
And negative values replace old values.
-D template PS->PDF conversion command line template [none]
-E Always try to embed fonts, regardless of licensing flags.
-I number Image cache life in hours [-2]
0: erase all old images and leave new images
-1: erase all old images and also erase new images
-2: ignore image cache
-K number Encryption key length [40]
-M Process MetaPost PostScript output
-O number Set maximum depth of open bookmark items [0]
-P number Set permission flags for PDF encryption [0x003C]
-S Enable PDF encryption
-V number Set PDF version [1.5]
All dimensions entered on the command line are "true" TeX dimensions.
Argument of "-s" lists physical page ranges separated by commas,
e.g., "-s 1-3,5-6".
Papersize is specified by paper format (e.g., "a4")
or by w<unit>,h<unit> (e.g., "20cm,30cm").
Email bug reports to dvipdfmx@tug.org.
What is the correct codes shuold I put or change in “Edit LaTeX build process” add-on, or am I doing this right?
Thanks!
After hours of research, I have totally solved this confusing problem.
The heart of this matter is that Anki’s LaTeX renderer used “pdfTeX” as a default while “chemfig” package can not be rendered correctly by it.
So I used “pdfLaTeX” replaced “pdfTeX” and used “ImageMagick” replced “dvipng” and made some changes: