Emacs组织模式:使用乳胶预览增加方程式数字

Ada*_*dam 5 emacs elisp org-mode

我注意到在Org模式下使用乳胶预览生成的等式数字不会增加到上面(1).有办法解决这个问题吗?

这是我的代码:

A numbered display equation:

\begin{equation}
y=\int_{-\infty}^{\infty}\frac{1}{1+x}dx\label{eq1}
\end{equation}

A second numbered equation:

\begin{equation}
z=qr^2-2\label{eq2}
\end{equation}
Run Code Online (Sandbox Code Playgroud)

谢谢!

-亚当

Tob*_*ias 5

最容易的是明确\tag的方程式.缺点是没有自动编号,优点是这也适用于使用MathJax导出html.

即使没有自动编号,你可以很容易地纠正编号query-replace-regexp替换\\tag{[0-9]+}\\tag{\,(1+ \#)}.

你的例子看起来像

A numbered display equation:

\begin{equation}
y=\int_{-\infty}^{\infty}\frac{1}{1+x}dx\label{eq1}\tag{1}
\end{equation}

A second numbered equation:

\begin{equation}
z=qr^2-2\label{eq2}\tag{2}
\end{equation}
Run Code Online (Sandbox Code Playgroud)


Alf*_* M. 5

我将我的评论作为答案,以便代码格式正确。这只是对托比亚斯答案的补充。

您可能想使用自动重新编号

(defun update-tag ()
  (interactive)
  (save-excursion
    (goto-char (point-min))
    (let ((count 1))
      (while (re-search-forward "\\tag{\\([0-9]+\\)}" nil t)
        (replace-match (format "%d" count) nil nil nil 1)
        (setq count (1+ count)))))
  )
Run Code Online (Sandbox Code Playgroud)

  • 谢谢阿尔弗雷德!这是太棒了。我想知道是否可以将其添加为每次运行 org Latex 预览时运行的挂钩?另外,似乎可以进一步细化以搜索方程中没有 \nonumber 标签的任何行号?这样,用户根本不必手动添加 \tag{1}...? (2认同)