Tunning org-latex-preview-impatient in Emacs

1. Installation

Declare package install in packages.el, in Doom1 for instance:

(package! org-latex-impatient
  :recipe (:host github
           :repo "yangsheng6810/org-latex-impatient"
           :branch "master"))

Add env setting of NODE_OPTIONS for avoiding failure in parsing xml when tex2svg generates svg with deprecation warning in xml:

(use-package org-latex-impatient
  :defer t
  :hook (org-mode . org-latex-impatient-mode)
  :init
  (setq org-latex-impatient-tex2svg-bin
        ;; location of tex2svg executable
        (file-truename "~/node_modules/mathjax-node-cli/bin/tex2svg"))
  (setenv "NODE_OPTIONS" "--no-deprecation")
  (setq max-image-size nil))

2. Org-latex-preview-impatient2 preview

Open a .org file and insert content like following latex segements, then enable org-latex-impatient-mode by M-x org-latex-impatient-mode . _20250622_213106screenshot.png

2.1. Inline Math

We are aware that the solutions to \(ax^{2}+bx+c=0\) are \(x_{1},x_{2} = \frac{-b \pm \sqrt{b^{2} - 4ac}}{2a}\)

2.2. Display Math

\[x_{1},x_{2} = \frac{-b \pm \sqrt{b^{2} - 4ac}}{2a}\]

3. Kelly Criterion

\begin{equation} f^* = \frac{bp - q}{b} \end{equation}

4. Bayes’ theorem

\begin{equation} P(A|B) = \frac{P(B|A)* P(A))}{P(B)} \end{equation}

5. Shannon–Hartley theorem

\begin{equation} C=B\log_{2}{(1+\frac{S}{N})} \end{equation}

6. Maxwell’s equations

\begin{equation} \begin{aligned} \nabla \cdot \mathbf{E} &= \frac{\rho}{\varepsilon_0} \quad &\text{(Gauss's law)} \\ \nabla \cdot \mathbf{B} &= 0 \quad &\text{(Gauss's law for magnetism)} \\ \nabla \times \mathbf{E} &= -\frac{\partial \mathbf{B}}{\partial t} \quad &\text{(Faraday's law)} \\ \nabla \times \mathbf{B} &= \mu_0 \mathbf{J} + \mu_0 \varepsilon_0 \frac{\partial \mathbf{E}}{\partial t} \quad &\text{(Ampère–Maxwell law)} \end{aligned} \end{equation}

7. Curvature

\begin{equation} \kappa(x) = \frac{ \left| f''(x) \right| }{ \left( 1 + \left(f'(x)\right)^2 \right)^{3/2} } \end{equation}

8. ROI, Return on Investment

\begin{equation} \text{ROI} = \frac{\text{收益} - \text{投资成本}}{\text{投资成本}} \times 100\% \end{equation}

9. Limit definition of the constant e

\begin{equation} e = \lim_{n \to \infty} \left( 1 + \frac{1}{n} \right)^n \end{equation}