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-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)