org-latex-preview: Change default latex command

* lisp/org-latex-preview.el (org-preview-latex-process-alist,
org-create-formula-image-async): Change the default latex command to
include the input file name.  Previously the input file was introduced
via process input for compatibility with preview.sty directives.  But
it appears that it's possible to simply set \RequirePackage{preview}
in the latex header without issues.
This commit is contained in:
Karthik Chikmagalur 2022-12-26 11:58:34 -08:00 committed by TEC
parent a8f433c31b
commit b47f2b23a8
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 17 additions and 15 deletions

View File

@ -135,7 +135,7 @@ All available processes and theirs documents can be found in
:image-input-type "dvi" :image-input-type "dvi"
:image-output-type "png" :image-output-type "png"
:image-size-adjust (1.0 . 1.0) :image-size-adjust (1.0 . 1.0)
:latex-compiler ("latex -interaction nonstopmode -output-directory %o") :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
:image-converter ("dvipng --follow -D %D -T tight -o %B-%%09d.png %f") :image-converter ("dvipng --follow -D %D -T tight -o %B-%%09d.png %f")
:transparent-image-converter :transparent-image-converter
("dvipng --follow -D %D -T tight -bg Transparent -o %B-%%09d.png %f")) ("dvipng --follow -D %D -T tight -bg Transparent -o %B-%%09d.png %f"))
@ -150,7 +150,7 @@ All available processes and theirs documents can be found in
:image-input-type "dvi" :image-input-type "dvi"
:image-output-type "svg" :image-output-type "svg"
:image-size-adjust (1.4 . 1.2) :image-size-adjust (1.4 . 1.2)
:latex-compiler ("latex -interaction nonstopmode -output-directory %o") :latex-compiler ("latex -interaction nonstopmode -output-directory %o %f")
:image-converter ("dvisvgm --page=1- --no-fonts --bbox=preview --scale=%S -o %B-%%9p.svg %f")) :image-converter ("dvisvgm --page=1- --no-fonts --bbox=preview --scale=%S -o %B-%%9p.svg %f"))
(imagemagick (imagemagick
:programs ("latex" "convert") :programs ("latex" "convert")
@ -570,15 +570,20 @@ MOVEFILES."
'(".dvi" ".xdv" ".pdf" ".tex" ".aux" ".log" '(".dvi" ".xdv" ".pdf" ".tex" ".aux" ".log"
".svg" ".png" ".jpg" ".jpeg" ".out"))) ".svg" ".png" ".jpg" ".jpeg" ".out")))
(latex-header (latex-header
(or (plist-get processing-info :latex-header) (concat
(org-latex-make-preamble (or (plist-get processing-info :latex-header)
(org-export-get-environment (org-export-get-backend 'latex)) (org-latex-make-preamble
org-format-latex-header (org-combine-plists
'snippet))) (org-export-get-environment (org-export-get-backend 'latex))
'(:time-stamp-file nil))
org-format-latex-header 'snippet))
"\n\\RequirePackage"
"[active,tightpage,auctex,displaymath,graphics,textmath,floats]"
"{preview}\n"))
(latex-compiler (plist-get processing-info :latex-compiler)) (latex-compiler (plist-get processing-info :latex-compiler))
(tmpdir temporary-file-directory) (texfilebase
(texfilebase (make-temp-name (make-temp-name
(expand-file-name "orgtex" tmpdir))) (expand-file-name "orgtex" temporary-file-directory)))
(texfile (concat texfilebase ".tex")) (texfile (concat texfilebase ".tex"))
(image-size-adjust (or (plist-get processing-info :image-size-adjust) (image-size-adjust (or (plist-get processing-info :image-size-adjust)
'(1.0 . 1.0))) '(1.0 . 1.0)))
@ -605,7 +610,8 @@ MOVEFILES."
string string
"\n\\end{document}\n")) "\n\\end{document}\n"))
(let* ((tex-process) (let* ((default-directory temporary-file-directory)
(tex-process)
(image-process) (image-process)
(basename (file-name-base texfilebase)) (basename (file-name-base texfilebase))
(out-dir (or (file-name-directory texfile) default-directory)) (out-dir (or (file-name-directory texfile) default-directory))
@ -629,10 +635,6 @@ MOVEFILES."
(dolist (e (delete (concat "." image-input-type) post-clean)) (dolist (e (delete (concat "." image-input-type) post-clean))
(when (file-exists-p (concat texfilebase e)) (when (file-exists-p (concat texfilebase e))
(delete-file (concat texfilebase e)))))))) (delete-file (concat texfilebase e))))))))
(process-send-string tex-process
(format-spec
"\\PassOptionsToPackage{noconfig,active,tightpage,auctex}{preview}\\AtBeginDocument{\\ifx\\ifPreview\\undefined\\RequirePackage[displaymath,floats,graphics,textmath,sections,footnotes]{preview}[2004/11/05]\\fi}\\input\\detokenize{%f}\n"
spec-tex))
(when (equal processing-type 'dvisvgm) (when (equal processing-type 'dvisvgm)
(let (inhibit-quit) (let (inhibit-quit)
(while (process-live-p tex-process) (while (process-live-p tex-process)