From mboxrd@z Thu Jan 1 00:00:00 1970 From: stardiviner Subject: preview embedded latex fragments error with my settings Date: Mon, 26 Mar 2018 23:49:33 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="------------E5770DC932013F9B4B8AAAF7" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:40419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f0UNU-0008I7-8q for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 11:49:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f0UNQ-0001qU-7f for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 11:49:44 -0400 Received: from mail-pl0-x236.google.com ([2607:f8b0:400e:c01::236]:44504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f0UNP-0001pd-Rx for emacs-orgmode@gnu.org; Mon, 26 Mar 2018 11:49:40 -0400 Received: by mail-pl0-x236.google.com with SMTP id 9-v6so12177678ple.11 for ; Mon, 26 Mar 2018 08:49:39 -0700 (PDT) Received: from [0.0.0.0] ([119.28.89.243]) by smtp.gmail.com with ESMTPSA id b3sm5640335pff.11.2018.03.26.08.49.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Mar 2018 08:49:37 -0700 (PDT) Content-Language: en-US List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: org-mode This is a multi-part message in MIME format. --------------E5770DC932013F9B4B8AAAF7 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit I have following settings to make org-mode export to PDF works better, like export with src block syntax highlighting with "minted", and support Chinese export with latex package "ctex" and specify default font etc all stuffs. I used to disabled org-mode startup preview latex fragments. Today I use [C-c C-x C-l] to preview latex fragments, it raised error (I shorten the very long error stack): ``` Debugger entered--Lisp error: (error "File \"/tmp/orgtexhCLnu9.dvi\" wasn’t produced.  Please adjust ‘dvisvgm’ part of ‘org-preview-latex-process-alist’.")   signal(error ("File \"/tmp/orgtexhCLnu9.dvi\" wasn’t produced.  Please adjust ‘dvisvgm’ part of ‘org-preview-latex-process-alist’."))   error("File \"/tmp/orgtexhCLnu9.dvi\" wasn't produced.  Please adjust `dvisvgm' part of `org-preview-latex-process-alist'.")   (if (org-file-newer-than-p output time) nil (error (format "File %S wasn't produced%s" output err-msg)))   (let* ((base-name (file-name-base source)) (full-name (file-truename source)) (out-dir (or (file-name-directory source) "./")) (output (expand-file-name (concat base-name "." ext) out-dir)) (time (current-time)) (err-msg (if (stringp err-msg) (concat ".  " err-msg) ""))) (let ((wconfig (current-window-configuration))) (unwind-protect (progn (cond ((functionp process) (funcall process (shell-quote-argument source))) ((consp process) (let ((log-buf (and log-buf (get-buffer-create log-buf))) (spec (append spec (list (cons 98 (shell-quote-argument base-name)) (cons 102 (shell-quote-argument source)) (cons 70 (shell-quote-argument full-name)) (cons 111 (shell-quote-argument out-dir)) (cons 79 (shell-quote-argument output)))))) (let ((--dolist-tail-- process)) (while --dolist-tail-- (let ((command (car --dolist-tail--))) (shell-command (format-spec command spec) log-buf) (setq --dolist-tail-- (cdr --dolist-tail--))))) (if log-buf (progn (save-current-buffer (set-buffer log-buf) (compilation-mode)))))) (t (error "No valid command to process %S%s" source err-msg)))) (set-window-configuration wconfig))) (if (org-file-newer-than-p output time) nil (error (format "File %S wasn't produced%s" output err-msg))) output)   org-compile-file("/tmp/orgtexhCLnu9.tex" ("latex -interaction nonstopmode -output-directory %o %f") "dvi" "Please adjust `dvisvgm' part of `org-preview-latex-process-alist'." #)   (let* ((err-msg (format "Please adjust `%s' part of `org-preview-latex-process-alist'." processing-type)).... (progn (delete-file (concat texfilebase e)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) image-output-file)   (let* ((processing-type (or processing-type org-preview-latex-default-process)) (processing-info .... (setq --dolist-tail-- (cdr --dolist-tail--))))) image-output-file))   org-create-formula-image("$\\LaTeX$" "/home/stardiviner/Org/Projects/Programming Projects/ltximg/org-ltximg_033e468d0c9a55db5895a459bfaa279c4e322eb9.svg" (:foreground default :background default :scale 2.0 :html-foreground "Black" :html-background "Transparent" :html-scale 2.5 :matchers ("begin" "$1" "$" "$$" "\\(" "\\[")) forbuffer dvisvgm)   (if (file-exists-p movefile) nil (org-create-formula-image value movefile options forbuffer processing-type))   (let* ((processing-info (cdr (assq processing-type org-preview-latex-process-alist)))....... (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))   (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context))..... (setq cnt (1+ cnt)) (if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type))))   (progn (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context)) ... (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))))   (if (memq type '(latex-environment latex-fragment)) (progn (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context)) (beg (org-element-property :begin context)) (end (save-excursion (goto-char (org-element-property :end context)) (skip-chars-backward " \15\11\n") (point)))) (cond ((eq processing-type 'mathjax).... (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type))))))   (let* ((context (org-element-context)) (type (org-element-type context))) (if (memq type '(latex-environment latex-fragment)) (progn (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context)) (beg (org-element-property :begin context)).... ((eq processing-type 'mathml) (if (org-format-latex-mathml-available-p) nil (user-error "LaTeX to MathML converter not configured")) (setq cnt (1+ cnt)) (if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))))))   (if (and overlays (eq (get-char-property (point) 'org-overlay-type) 'org-latex-overlay)) nil (let* ((context (org-element-context)) (type (org-element-type context))) (if (memq type '(latex-environment latex-fragment)) (progn (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context)) (beg (org-element-property :begin context)) (end (save-excursion (goto-char (org-element-property :end context))......(if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type))))))))   (while (re-search-forward math-regexp end t) (if (and overlays (eq (get-char-property (point) 'org-overlay-type) 'org-latex-overlay)) nil (let* ((context (org-element-context)) (type (org-element-type context))) (if (memq type '(latex-environment latex-fragment)).... (setq cnt (1+ cnt)) (if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))))))))   (let* ((math-regexp "\\$\\|\\\\[([]\\|^[ \11]*\\\\begin{[A-Za-z0-9*]+}") (cnt 0) checkdir-flag) (goto-char (or beg (point-min))) (if (and overlays (memq processing-type '(dvipng imagemagick))) (progn (overlay-recenter (or end (point-max))))).... (setq cnt (1+ cnt)) (if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type))))))))))   (if (eq processing-type 'verbatim) nil (let* ((math-regexp "\\$\\|\\\\[([]\\|^[ \11]*\\\\begin{[A-Za-z0-9*]+}") (cnt 0) checkdir-flag) (goto-char (or beg (point-min)))..... (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))))))))))   org-format-latex("ltximg/org-ltximg" 160825 160845 "/home/stardiviner/Org/Projects/Programming Projects/" overlays "Creating images for section..." forbuffer dvisvgm)   (let ((file (buffer-file-name (buffer-base-buffer)))) (org-format-latex (concat org-preview-latex-image-directory "org-ltximg") beg end (if (or (not file) (file-remote-p file)) temporary-file-directory default-directory) 'overlays msg 'forbuffer org-preview-latex-default-process))   (let (beg end msg) (cond ((or (equal arg '(16)) (and (equal arg '(4)) (progn (defvar org-called-with-limited-levels) (defvar org-outline-regexp) (defvar outline-regexp)..... (org-format-latex (concat org-preview-latex-image-directory "org-ltximg") beg end (if (or (not file) (file-remote-p file)) temporary-file-directory default-directory) 'overlays msg 'forbuffer org-preview-latex-default-process)) (message (concat msg "done")))   (save-excursion (let (beg end msg) (cond ((or (equal arg '(16)) (and (equal arg '(4)) (progn (defvar org-called-with-limited-levels) (defvar org-outline-regexp) (defvar outline-regexp) (defvar org-outline-regexp-bol) (let* ((org-called-with-limited-levels t) (org-outline-regexp (org-get-limited-outline-regexp)) (outline-regexp org-outline-regexp) (org-outline-regexp-bol (concat "^" org-outline-regexp)))..... (let ((file (buffer-file-name (buffer-base-buffer)))) (org-format-latex (concat org-preview-latex-image-directory "org-ltximg") beg end (if (or (not file) (file-remote-p file)) temporary-file-directory default-directory) 'overlays msg 'forbuffer org-preview-latex-default-process)) (message (concat msg "done"))))))   (if (display-graphic-p) (progn (catch 'exit (save-excursion (let (beg end msg) (cond ((or (equal arg '(16)) (and (equal arg '(4)) (progn (defvar org-called-with-limited-levels) (defvar org-outline-regexp) (defvar outline-regexp) (defvar org-outline-regexp-bol) (let* ((org-called-with-limited-levels t) (org-outline-regexp (org-get-limited-outline-regexp)) (outline-regexp org-outline-regexp) (org-outline-regexp-bol (concat "^" org-outline-regexp))) (org-before-first-heading-p)))))......(file-remote-p file)) temporary-file-directory default-directory) 'overlays msg 'forbuffer org-preview-latex-default-process)) (message (concat msg "done")))))))   org-toggle-latex-fragment(nil)   funcall-interactively(org-toggle-latex-fragment nil)   call-interactively(org-toggle-latex-fragment nil nil)   command-execute(org-toggle-latex-fragment) ``` Here is a simple version config might reproduce my problem: ```elisp (setq org-preview-latex-default-process 'dvisvgm) ; generate SVG for better image. (setq org-latex-image-default-width "2.0\\linewidth") (setq org-format-latex-options       (plist-put org-format-latex-options :scale 2.0)) ; adjust LaTeX preview image size. (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\setmainfont{DejaVu Sans}")) (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\setsansfont{DejaVu Serif}")) (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\setmonofont{DejaVu Sans Mono}")) (setq-default TeX-engine 'xetex) (add-to-list 'org-latex-packages-alist '("" "ctex")) (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\usepackage[utf8]{ctex}")) ;;; support for export Chinese LaTeX to PDF (setf org-latex-default-packages-alist       (remove '("AUTO" "inputenc" t ("pdflatex")) org-latex-default-packages-alist)) ;;; set font for Chinese (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\usepackage{fontspec}")) (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\setCJKmainfont[scale=0.6]{WenQuanYi Micro Hei}")) (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\setCJKsansfont{WenQuanYi Micro Hei}")) (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\setCJKmonofont{WenQuanYi Micro Hei Mono}")) ;; set PDF file default font size. (Chinese) (setq org-format-latex-header       (replace-regexp-in-string        "documentclass{article}" "documentclass[fontsize=5pt]{article}"        org-format-latex-header)) ;; Chinese linebreak (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\XeTeXlinebreaklocale \"zh\"")) (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt")) ;; CJKulem (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\usepackage{CJKulem}")) ;; page style (add-to-list 'org-latex-packages-alist '("" "fancyhdr")) (setq org-format-latex-header       (concat org-format-latex-header "\n" "\\pagestyle{fancy}")) ``` --------------E5770DC932013F9B4B8AAAF7 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

I have following settings to make org-mode export to PDF works better, like export with src block syntax highlighting with "minted", and support Chinese export with latex package "ctex" and specify default font etc all stuffs.

I used to disabled org-mode startup preview latex fragments. Today I use [C-c C-x C-l] to preview latex fragments, it raised error (I shorten the very long error stack):

```

Debugger entered--Lisp error: (error "File \"/tmp/orgtexhCLnu9.dvi\" wasn’t produced.  Please adjust ‘dvisvgm’ part of ‘org-preview-latex-process-alist’.")
  signal(error ("File \"/tmp/orgtexhCLnu9.dvi\" wasn’t produced.  Please adjust ‘dvisvgm’ part of ‘org-preview-latex-process-alist’."))
  error("File \"/tmp/orgtexhCLnu9.dvi\" wasn't produced.  Please adjust `dvisvgm' part of `org-preview-latex-process-alist'.")
  (if (org-file-newer-than-p output time) nil (error (format "File %S wasn't produced%s" output err-msg)))
  (let* ((base-name (file-name-base source)) (full-name (file-truename source)) (out-dir (or (file-name-directory source) "./")) (output (expand-file-name (concat base-name "." ext) out-dir)) (time (current-time)) (err-msg (if (stringp err-msg) (concat ".  " err-msg) ""))) (let ((wconfig (current-window-configuration))) (unwind-protect (progn (cond ((functionp process) (funcall process (shell-quote-argument source))) ((consp process) (let ((log-buf (and log-buf (get-buffer-create log-buf))) (spec (append spec (list (cons 98 (shell-quote-argument base-name)) (cons 102 (shell-quote-argument source)) (cons 70 (shell-quote-argument full-name)) (cons 111 (shell-quote-argument out-dir)) (cons 79 (shell-quote-argument output)))))) (let ((--dolist-tail-- process)) (while --dolist-tail-- (let ((command (car --dolist-tail--))) (shell-command (format-spec command spec) log-buf) (setq --dolist-tail-- (cdr --dolist-tail--))))) (if log-buf (progn (save-current-buffer (set-buffer log-buf) (compilation-mode)))))) (t (error "No valid command to process %S%s" source err-msg)))) (set-window-configuration wconfig))) (if (org-file-newer-than-p output time) nil (error (format "File %S wasn't produced%s" output err-msg))) output)
  org-compile-file("/tmp/orgtexhCLnu9.tex" ("latex -interaction nonstopmode -output-directory %o %f") "dvi" "Please adjust `dvisvgm' part of `org-preview-latex-process-alist'." #<buffer *Org Preview LaTeX Output*>)
  (let* ((err-msg (format "Please adjust `%s' part of `org-preview-latex-process-alist'." processing-type)).... (progn (delete-file (concat texfilebase e)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) image-output-file)
  (let* ((processing-type (or processing-type org-preview-latex-default-process)) (processing-info .... (setq --dolist-tail-- (cdr --dolist-tail--))))) image-output-file))
  org-create-formula-image("$\\LaTeX$" "/home/stardiviner/Org/Projects/Programming Projects/ltximg/org-ltximg_033e468d0c9a55db5895a459bfaa279c4e322eb9.svg" (:foreground default :background default :scale 2.0 :html-foreground "Black" :html-background "Transparent" :html-scale 2.5 :matchers ("begin" "$1" "$" "$$" "\\(" "\\[")) forbuffer dvisvgm)
  (if (file-exists-p movefile) nil (org-create-formula-image value movefile options forbuffer processing-type))
  (let* ((processing-info (cdr (assq processing-type org-preview-latex-process-alist)))....... (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))
  (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context))..... (setq cnt (1+ cnt)) (if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type))))
  (progn (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context)) ... (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))))
  (if (memq type '(latex-environment latex-fragment)) (progn (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context)) (beg (org-element-property :begin context)) (end (save-excursion (goto-char (org-element-property :end context)) (skip-chars-backward " \15\11\n") (point)))) (cond ((eq processing-type 'mathjax).... (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type))))))
  (let* ((context (org-element-context)) (type (org-element-type context))) (if (memq type '(latex-environment latex-fragment)) (progn (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context)) (beg (org-element-property :begin context)).... ((eq processing-type 'mathml) (if (org-format-latex-mathml-available-p) nil (user-error "LaTeX to MathML converter not configured")) (setq cnt (1+ cnt)) (if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))))))
  (if (and overlays (eq (get-char-property (point) 'org-overlay-type) 'org-latex-overlay)) nil (let* ((context (org-element-context)) (type (org-element-type context))) (if (memq type '(latex-environment latex-fragment)) (progn (let ((block-type (eq type 'latex-environment)) (value (org-element-property :value context)) (beg (org-element-property :begin context)) (end (save-excursion (goto-char (org-element-property :end context))......(if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type))))))))
  (while (re-search-forward math-regexp end t) (if (and overlays (eq (get-char-property (point) 'org-overlay-type) 'org-latex-overlay)) nil (let* ((context (org-element-context)) (type (org-element-type context))) (if (memq type '(latex-environment latex-fragment)).... (setq cnt (1+ cnt)) (if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))))))))
  (let* ((math-regexp "\\$\\|\\\\[([]\\|^[ \11]*\\\\begin{[A-Za-z0-9*]+}") (cnt 0) checkdir-flag) (goto-char (or beg (point-min))) (if (and overlays (memq processing-type '(dvipng imagemagick))) (progn (overlay-recenter (or end (point-max))))).... (setq cnt (1+ cnt)) (if msg (progn (message msg cnt))) (goto-char beg) (delete-region beg end) (insert (org-format-latex-as-mathml value block-type prefix dir))) (t (error "Unknown conversion process %s for LaTeX fragments" processing-type))))))))))
  (if (eq processing-type 'verbatim) nil (let* ((math-regexp "\\$\\|\\\\[([]\\|^[ \11]*\\\\begin{[A-Za-z0-9*]+}") (cnt 0) checkdir-flag) (goto-char (or beg (point-min)))..... (t (error "Unknown conversion process %s for LaTeX fragments" processing-type)))))))))))
  org-format-latex("ltximg/org-ltximg" 160825 160845 "/home/stardiviner/Org/Projects/Programming Projects/" overlays "Creating images for section..." forbuffer dvisvgm)
  (let ((file (buffer-file-name (buffer-base-buffer)))) (org-format-latex (concat org-preview-latex-image-directory "org-ltximg") beg end (if (or (not file) (file-remote-p file)) temporary-file-directory default-directory) 'overlays msg 'forbuffer org-preview-latex-default-process))
  (let (beg end msg) (cond ((or (equal arg '(16)) (and (equal arg '(4)) (progn (defvar org-called-with-limited-levels) (defvar org-outline-regexp) (defvar outline-regexp)..... (org-format-latex (concat org-preview-latex-image-directory "org-ltximg") beg end (if (or (not file) (file-remote-p file)) temporary-file-directory default-directory) 'overlays msg 'forbuffer org-preview-latex-default-process)) (message (concat msg "done")))
  (save-excursion (let (beg end msg) (cond ((or (equal arg '(16)) (and (equal arg '(4)) (progn (defvar org-called-with-limited-levels) (defvar org-outline-regexp) (defvar outline-regexp) (defvar org-outline-regexp-bol) (let* ((org-called-with-limited-levels t) (org-outline-regexp (org-get-limited-outline-regexp)) (outline-regexp org-outline-regexp) (org-outline-regexp-bol (concat "^" org-outline-regexp)))..... (let ((file (buffer-file-name (buffer-base-buffer)))) (org-format-latex (concat org-preview-latex-image-directory "org-ltximg") beg end (if (or (not file) (file-remote-p file)) temporary-file-directory default-directory) 'overlays msg 'forbuffer org-preview-latex-default-process)) (message (concat msg "done"))))))
  (if (display-graphic-p) (progn (catch 'exit (save-excursion (let (beg end msg) (cond ((or (equal arg '(16)) (and (equal arg '(4)) (progn (defvar org-called-with-limited-levels) (defvar org-outline-regexp) (defvar outline-regexp) (defvar org-outline-regexp-bol) (let* ((org-called-with-limited-levels t) (org-outline-regexp (org-get-limited-outline-regexp)) (outline-regexp org-outline-regexp) (org-outline-regexp-bol (concat "^" org-outline-regexp))) (org-before-first-heading-p)))))......(file-remote-p file)) temporary-file-directory default-directory) 'overlays msg 'forbuffer org-preview-latex-default-process)) (message (concat msg "done")))))))
  org-toggle-latex-fragment(nil)
  funcall-interactively(org-toggle-latex-fragment nil)
  call-interactively(org-toggle-latex-fragment nil nil)
  command-execute(org-toggle-latex-fragment)
```

Here is a simple version config might reproduce my problem:

```elisp

(setq org-preview-latex-default-process 'dvisvgm) ; generate SVG for better image.
(setq org-latex-image-default-width "2.0\\linewidth")
(setq org-format-latex-options
      (plist-put org-format-latex-options :scale 2.0)) ; adjust LaTeX preview image size.
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\setmainfont{DejaVu Sans}"))
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\setsansfont{DejaVu Serif}"))
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\setmonofont{DejaVu Sans Mono}"))
(setq-default TeX-engine 'xetex)
(add-to-list 'org-latex-packages-alist '("" "ctex"))
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\usepackage[utf8]{ctex}"))

;;; support for export Chinese LaTeX to PDF
(setf org-latex-default-packages-alist
      (remove '("AUTO" "inputenc" t ("pdflatex")) org-latex-default-packages-alist))
;;; set font for Chinese
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\usepackage{fontspec}"))
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\setCJKmainfont[scale=0.6]{WenQuanYi Micro Hei}"))
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\setCJKsansfont{WenQuanYi Micro Hei}"))
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\setCJKmonofont{WenQuanYi Micro Hei Mono}"))
;; set PDF file default font size. (Chinese)
(setq org-format-latex-header
      (replace-regexp-in-string
       "documentclass{article}"
       "documentclass[fontsize=5pt]{article}"
       org-format-latex-header))
;; Chinese linebreak
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\XeTeXlinebreaklocale \"zh\""))
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\XeTeXlinebreakskip = 0pt plus 1pt minus 0.1pt"))
;; CJKulem
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\usepackage{CJKulem}"))
;; page style
(add-to-list 'org-latex-packages-alist '("" "fancyhdr"))
(setq org-format-latex-header
      (concat org-format-latex-header "\n" "\\pagestyle{fancy}"))

```

--------------E5770DC932013F9B4B8AAAF7--