From 1b1373f3c9a08d2ea06335686fdbda68341893f2 Mon Sep 17 00:00:00 2001 From: TEC Date: Fri, 17 Mar 2023 01:25:18 +0800 Subject: [PATCH] org-latex-preview: Emit warning when hyperref seen * lisp/org-latex-preview.el (org-latex-preview--latex-preview-filter): If during LaTeX compilation hyperref seems to be present, emit a warning mentioning the sizing issue it is known to cause. --- lisp/org-latex-preview.el | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lisp/org-latex-preview.el b/lisp/org-latex-preview.el index afa76cb79..c7476eb85 100644 --- a/lisp/org-latex-preview.el +++ b/lisp/org-latex-preview.el @@ -1669,7 +1669,20 @@ fragments in EXTENDED-INFO." (unless (plist-get extended-info :fontsize) (when (save-excursion (re-search-forward "^Preview: Fontsize \\([0-9]+\\)pt$" nil t)) - (plist-put extended-info :fontsize (string-to-number (match-string 1))))) + (plist-put extended-info :fontsize (string-to-number (match-string 1))) + ;; Since at this point can infer that the preamble logging is complete, + ;; we can also check for hyperref and warn if it seems to be used, + ;; as it is currently known to cause issues. + (save-excursion + (goto-char (point-min)) + (when (if (and org-latex-preview-use-precompilation + (re-search-forward "^PRELOADED FILES:" nil t)) + (re-search-forward "^ *hyperref\\.sty" nil t) + (re-search-forward "^(.*hyperref/hyperref\\.sty" nil t)) + (display-warning + '(org latex-preview hyperref) + "Hyperref seems to be loaded, this is known to cause issues with the reported size information" + :warning))))) (let ((preview-start-re "^! Preview: Snippet \\([0-9]+\\) started.\n<-><->\n *\nl\\.\\([0-9]+\\)[^\n]+\n") (preview-end-re