diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el index 629d11bac..d554d4820 100644 --- a/lisp/org-latex-preview.el +++ b/lisp/org-latex-preview.el @@ -1492,12 +1492,24 @@ The path of the created LaTeX file is returned." "\n\\usepackage[active,tightpage,auctex]{preview}\n")) (write-region-inhibit-fsync t) (coding-system-for-write buffer-file-coding-system)) + (when org-latex-preview-use-precompilation + (if-let ((format-file (org-latex-preview-precompile processing-info header))) + ;; Replace header with .fmt file path. + (setq header (concat "%& " (file-name-sans-extension format-file))) + (display-warning + '(org latex-preview disable-local-precompile) + (concat "Precompile failed, disabling LaTeX preview precompile in this buffer." + "\n To renable, run `(setq-local org-latex-preview-use-precompilation t)' or reopen this buffer." + (pcase (plist-get processing-info :latex-processor) + ("lualatex" + "\n LuaLaTeX is known to be problematic, if you might be able to help please get in touch with emacs-orgmode@gnu.org.") + ("xelatex" + ;; Note: might be helpful. + "\n The current XeTeX approach does not support fontspec, if you might be able to help please get in touch with emacs-orgmode@gnu.org.")) + "\n ")) + (setq-local org-latex-preview-use-precompilation nil))) (with-temp-file tex-temp-name - (insert (if-let ((format-file - (and org-latex-preview-use-precompilation - (org-latex-preview-precompile processing-info header)))) - (concat "%& " (file-name-sans-extension format-file)) - header)) + (insert header) ;; The \abovedisplayskip length must be set after \begin{document} because ;; it is usually set during the font size intialisation that occurs at ;; \begin{document}. We can either modify the \normalsize command to set