Emacs 预览版-latex

发布于 2024-12-18 21:15:11 字数 309 浏览 2 评论 0原文

我使用 Preview-latex 在 Emacs 窗口中显示 LaTeX 结果。我使用点预览在代码和输出之间来回切换。但是,如果我没有使用 Latex 代码(错误地,也许我错过了一两行),则预览点会尝试编译所有内容,调出“其他”窗口,然后失败。所有这些过程都会减慢速度。

我的问题是如何禁用此编译(尝试)?如果无法进行切换,则预览不应执行任何操作。有预览乳胶的设置吗?或者也许是我可以重写的函数?

error in process sentinel: LaTeX found no preview images

谢谢,

I use preview-latex for displaying LaTeX results in an Emacs window. I use preview-at-point to toggle back and forth between code and output. However if I am not on Latex code (by mistake, maybe I missed my intended line by one, or two) then preview-at-point tries to compile everything, brings up the "other" window, and fails. All this process slows things down.

My question is how can I disable this compilation (attempt)? If no toggling is possible, then preview should not do anything. Is there a setting for preview-latex for that? Or perhaps a function I can override?

error in process sentinel: LaTeX found no preview images

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

折戟 2024-12-25 21:15:11

真正的工作是由 preview-region 完成的,因此我们可以建议在某些情况下将其设为 noop。以下内容并不完美,因为我认为没有办法提前知道将要预览的内容 - 用户可以指定要预览的任何环境或宏。例如,如果您只关心数学预览,那么您可以删除 previewable-environments 部分。

(defvar previewable-environments
  "List of environments that should be previewed."
  '("tabular" "tabular*" "tikzpicture" "..."))

(defadvice preview-region (around preview-at-point-no-long-pauses activate)
  "Make `preview-at-point' a no-op if mark is inactive and point is not on a preview."
  (when (or (not (eq this-command 'preview-at-point))
            (TeX-active-mark)
            (texmathp)
            (member (LaTeX-current-environment) previewable-environments))
    ad-do-it))

The real work is done by preview-region so we can advise that to be a noop in certain cases. The following is not perfect since I don't think there is a way to know ahead of time what is going to previewed—the user can specify any environment or macro to be previewed. If, for example, you only care about math previews then you can remove the previewable-environments pieces.

(defvar previewable-environments
  "List of environments that should be previewed."
  '("tabular" "tabular*" "tikzpicture" "..."))

(defadvice preview-region (around preview-at-point-no-long-pauses activate)
  "Make `preview-at-point' a no-op if mark is inactive and point is not on a preview."
  (when (or (not (eq this-command 'preview-at-point))
            (TeX-active-mark)
            (texmathp)
            (member (LaTeX-current-environment) previewable-environments))
    ad-do-it))
昔日梦未散 2024-12-25 21:15:11

已接受答案的一种变体:如果代码位于方程式上,则代码将触发预览切换,但我也希望当我不在任何数学片段上时预览整个文档。其代码是

(defvar previewable-environments
  "List of environments that should be previewed."
  '("tabular" "tabular*" "tikzpicture" "..."))

(defadvice preview-region (around preview-at-point-no-long-pauses activate)
  "Make `preview-at-point' a no-op if mark is inactive and point is not on a preview."
  (message "preview-region")
  (if (or (not (eq this-command 'preview-at-point))
            (TeX-active-mark)
            (texmathp)
            (member (LaTeX-current-environment) previewable-environments))
    ad-do-it
    (preview-section)
    )
  )

A variation on the accepted answer: The code will trigger preview toggle if it is on an equation, but I would also like the entire document to be previewed when I am not on any math snippet. The code for that is

(defvar previewable-environments
  "List of environments that should be previewed."
  '("tabular" "tabular*" "tikzpicture" "..."))

(defadvice preview-region (around preview-at-point-no-long-pauses activate)
  "Make `preview-at-point' a no-op if mark is inactive and point is not on a preview."
  (message "preview-region")
  (if (or (not (eq this-command 'preview-at-point))
            (TeX-active-mark)
            (texmathp)
            (member (LaTeX-current-environment) previewable-environments))
    ad-do-it
    (preview-section)
    )
  )
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文