放假无聊配置了下,下面过程与配置供参考
就像楼上说的你首先要先清楚如何用 Latex 生成带中文的 PDF,推荐用 ctex 宏包,
#+LaTeX_HEADER: \usepackage[UTF8]{ctex}
或者
(setq org-latex-packages-alist
'(("fontset=macnew,UTF8" "ctex" t)))
然后再生成图片的时候就会提示
org-compile-file: File "/var/folders/_q/t4z901gd5nz2syx8nc8rkt9m0000gq/T/orgtexg15boA.dvi" wasn’t produced. Please adjust ‘dvisvgm’ part of ‘org-preview-latex-process-alist’.
查看 org-preview-latex-process-alist
的值,发现是默认用的 latex or pdflatex。用 pdflatex 编译的话会提示 CTeX fontset 'mac' is unavailable in current
,具体详见 CTEX 宏集手册,字体原因,我也不是很熟悉,懒得折腾了,换成 xelatex。
然后就根据上面目录里的临时 tex 文件(orgtexg15boA.tex)调整命令直到生成图片,就把 org-preview-latex-process-alist
改好了
(setq org-preview-latex-default-process 'dvisvgm)
(setq org-preview-latex-process-alist
'((dvisvgm :programs
("xelatex" "dvisvgm")
:description "xdv > svg" :message "you need to install the programs: xelatex and dvisvgm." :use-xcolor t :image-input-type "xdv" :image-output-type "svg" :image-size-adjust
(1.7 . 1.5)
:latex-compiler
("xelatex -no-pdf -interaction nonstopmode -output-directory %o %f")
:image-converter
("dvisvgm %f -n -b min -c %S -o %O"))
(imagemagick :programs
("xelatex" "convert")
:description "pdf > png" :message "you need to install the programs: xelatex and imagemagick." :use-xcolor t :image-input-type "pdf" :image-output-type "png" :image-size-adjust
(1.0 . 1.0)
:latex-compiler
("xelatex -interaction nonstopmode -output-directory %o %f")
:image-converter
("convert -density %D -trim -antialias %f -quality 100 %O"))))
另 dvipng 不支持 xelatex 生成的 xdv,加上图片也不清楚,不推荐用。以及没装 imagemagick,我只是简单改了下,没测试。