From b47f2b23a8b8c82cd2afa29be72d9e40e301f92e Mon Sep 17 00:00:00 2001 From: Karthik Chikmagalur Date: Mon, 26 Dec 2022 11:58:34 -0800 Subject: [PATCH] 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. --- lisp/org-latex-preview.el | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el index 78c8dda11..d87cf6daf 100644 --- a/lisp/org-latex-preview.el +++ b/lisp/org-latex-preview.el @@ -135,7 +135,7 @@ All available processes and theirs documents can be found in :image-input-type "dvi" :image-output-type "png" :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") :transparent-image-converter ("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-output-type "svg" :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")) (imagemagick :programs ("latex" "convert") @@ -570,15 +570,20 @@ MOVEFILES." '(".dvi" ".xdv" ".pdf" ".tex" ".aux" ".log" ".svg" ".png" ".jpg" ".jpeg" ".out"))) (latex-header - (or (plist-get processing-info :latex-header) - (org-latex-make-preamble - (org-export-get-environment (org-export-get-backend 'latex)) - org-format-latex-header - 'snippet))) + (concat + (or (plist-get processing-info :latex-header) + (org-latex-make-preamble + (org-combine-plists + (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)) - (tmpdir temporary-file-directory) - (texfilebase (make-temp-name - (expand-file-name "orgtex" tmpdir))) + (texfilebase + (make-temp-name + (expand-file-name "orgtex" temporary-file-directory))) (texfile (concat texfilebase ".tex")) (image-size-adjust (or (plist-get processing-info :image-size-adjust) '(1.0 . 1.0))) @@ -605,7 +610,8 @@ MOVEFILES." string "\n\\end{document}\n")) - (let* ((tex-process) + (let* ((default-directory temporary-file-directory) + (tex-process) (image-process) (basename (file-name-base texfilebase)) (out-dir (or (file-name-directory texfile) default-directory)) @@ -629,10 +635,6 @@ MOVEFILES." (dolist (e (delete (concat "." image-input-type) post-clean)) (when (file-exists-p (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) (let (inhibit-quit) (while (process-live-p tex-process)