From: stardiviner <numbchild@gmail.com>
To: org-mode <emacs-orgmode@gnu.org>
Subject: preview embedded latex fragments error with my settings
Date: Mon, 26 Mar 2018 23:55:48 +0800 [thread overview]
Message-ID: <be4c6f49-75dc-ac93-a179-afc03ccebeb9@gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 9158 bytes --]
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
error stack manuallyfor easy to read):
```
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)) ...... (let
((--dolist-tail-- post-clean)) (while --dolist-tail-- (let ((e (car
--dolist-tail--))) (if (file-exists-p (concat texfilebase e)) (progn
(delete-file (concat texfilebase e)))) (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))) (face (face-at-point)) (fg (let
((color (plist-get org-format-latex-options :foreground))) (if (and
forbuffer (eq color 'auto)) (face-attribute face :foreground nil
'default) color)))..... (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)) (beg (org-element-property :begin
context)) (end (save-excursion (goto-char (org-element-property :end
context))......(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))...... (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 (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))..... (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))...... (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)))..... (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))......... (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))) (if (and overlays (memq
processing-type '(dvipng imagemagick))) (progn (overlay-recenter (or end
(point-max))))).....(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)))))))))))
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)..... '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)..... 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"))))
(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).....(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)..... (progn
(message "LaTeX fragment images removed from section") (throw 'exit
nil)) (setq msg "Creating images for section...")))))) (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")))))))
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)
```
The attachment is a simple config that you can reproduce this problem.
[-- Attachment #1.2: Type: text/html, Size: 17815 bytes --]
[-- Attachment #2: reproduce-config.el --]
[-- Type: text/x-emacs-lisp, Size: 4263 bytes --]
(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-options
(plist-put org-format-latex-options :html-scale 2.5)) ; adjust HTML exporting LaTeX image size.
;;; Org export to LaTeX default headers.
;; set LaTeX default font
(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}"))
;;; export to PDF with src blocks syntax highlighting.
(setq org-latex-listings 'minted)
(add-to-list 'org-latex-packages-alist '("" "minted"))
(setq org-latex-minted-options
'(("frame" "lines")
("linenos" "true") ; enable number lines
;; ("frame" "single") ; box frame
("escapeinside" "$$") ; escape to LaTeX between the two characters specified in $$.
("mathescape" "true") ; escape and interrupt math in src block
("texcomments" "true") ; enable LaTeX code inside comments
("numbersep" "5pt") ; gap between numbers and start of line
("framesep" "2mm") ; distance between frame and content
;; ("fontsize" "??") ; font size in code block
("breaklines" "true")
))
;; (add-to-list 'org-latex-minted-langs '(clojure "Clojure"))
;; (add-to-list 'org-latex-pdf-process
;; "latexmk -shell-escape -bibtex -xelatex -g -f %f")
;;; Org-mode export to -> Chinese TeX (ctex) -> PDF
;;; set default LaTeX engine to xetex
(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}"))
;; (setq org-format-latex-header
;; (concat org-format-latex-header "\n" "\\usepackage{xeCJK}"))
;;; set latex to xelatex engine.
(setq org-latex-pdf-process
'("xelatex -8bit --shell-escape -interaction=nonstopmode -output-directory %o %f"
"xelatex -8bit --shell-escape -interaction=nonstopmode -output-directory %o %f"
"xelatex -8bit --shell-escape -interaction=nonstopmode -output-directory %o %f"))
;; specify src block syntax highlighting color scheme
(setq org-format-latex-header
(concat org-format-latex-header "\n" "\\usemintedstyle{manni}"))
;; set src block
(setq org-format-latex-header
(concat org-format-latex-header "\n"
"\\lstset{frame=shadowbox,
numbers=left,
numberstyle= \\tiny,
keywordstyle= \\color{ blue!70},commentstyle=\\color{red!50!green!50!blue!50},
rulesepcolor= \\color{ red!20!green!20!blue!20}"))
;;; 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}"))
next reply other threads:[~2018-03-26 15:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-26 15:55 stardiviner [this message]
2018-03-26 16:20 ` preview embedded latex fragments error with my settings Nicolas Goaziou
2018-03-27 0:57 ` stardiviner
2018-03-27 4:48 ` John Kitchin
2018-03-27 7:56 ` Alan Schmitt
2018-03-27 10:12 ` stardiviner
2018-03-27 13:38 ` Alan Schmitt
-- strict thread matches above, loose matches on Subject: below --
2018-03-26 15:49 stardiviner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=be4c6f49-75dc-ac93-a179-afc03ccebeb9@gmail.com \
--to=numbchild@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.