org-latex-preview: Use icon for non-numbered eqns

* lisp/org-latex-preview.el (org-latex-preview--get-preamble,
org-latex-preview--single-eqn-format): When numbering is turned off (via
`org-latex-preview-numbered'), instead of always showing "(1)" as the
equation number, use a diamond symbol, and in multiline environments
show +offset.  The LaTeX setup for this is stored in the new const
`org-latex-preview--single-eqn-format'.
This commit is contained in:
TEC 2023-03-14 10:31:42 +08:00
parent fed2ebc16a
commit 7340c4fae7
Signed by: tec
SSH Key Fingerprint: SHA256:eobz41Mnm0/iYWBvWThftS0ElEs1ftBr6jamutnXc/A
1 changed files with 15 additions and 5 deletions

View File

@ -1322,6 +1322,13 @@ previews."
(add-hook 'org-mode-hook #'org-latex-preview--clear-preamble-cache)
(defconst org-latex-preview--single-eqn-format
"\n\\makeatletter
\\renewcommand{\\theequation}{\\(\\diamond\\)\\ifnum\\value{equation}>1%
\\,+\\,\\@arabic{\\numexpr\\value{equation}-1\\relax}\\fi}
\\makeatother"
"A LaTeX preamble snippet that sets \"\"-based equation numbers.")
(defun org-latex-preview--get-preamble (&optional buf)
"Obtain the LaTeX preview for snippet preview in BUF."
(with-current-buffer (or buf (current-buffer))
@ -1346,12 +1353,15 @@ previews."
(font-lock-mode -1)
(setq info
(org-export--annotate-info (org-export-get-backend 'latex) info))
(concat
(org-latex-make-preamble
(org-combine-plists
(org-export-get-environment
(org-export-get-backend 'latex))
'(:time-stamp-file nil))
org-latex-preview-preamble 'snippet))))))
(org-combine-plists
(org-export-get-environment
(org-export-get-backend 'latex))
'(:time-stamp-file nil))
org-latex-preview-preamble 'snippet)
(and (not org-latex-preview-numbered)
org-latex-preview--single-eqn-format)))))))
(defun org-latex-preview--create-tex-file (processing-info fragments)
"Create a LaTeX file based on PROCESSING-INFO and FRAGMENTS.