gpt4 book ai didi

emacs - Emacs 中 LaTeX 的代码折叠

转载 作者:行者123 更新时间:2023-12-03 22:29:19 24 4
gpt4 key购买 nike

是否有 Emacs 次要模式(或一段 elisp 代码)可以让您在 LaTeX 模式下有选择地隐藏/显示环境?例如,我想移动到一个长 \begin{figure} 的开头。阻止,点击一个按键,然后隐藏该图形环境的内容。与 \begin{proof} 类似等等,理想情况下甚至是 \subsection s。

这可能吗?我刚试过 hs-minor-mode , allout-mode , 和 outline-minor-mode ,但他们中的大多数人不承认 LaTeX 的环境,例如hs-minor-mode 因“扫描错误:括号不平衡”而失败。我不想输入明确的折叠标记,如 {{{ 如 folding-mode .

[理想情况下,如果折叠是persistent 那就太好了。 ,但我看到这个问题还没有被接受的答案。]

最佳答案

AUCTeX 折叠:http://www.gnu.org/software/auctex/manual/auctex.html#Folding

A popular complaint about markup languages like TeX and LaTeX is that there is too much clutter in the source text and that one cannot focus well on the content. There are macros where you are only interested in the content they are enclosing, like font specifiers where the content might already be fontified in a special way by font locking. Or macros the content of which you only want to see when actually editing it, like footnotes or citations. Similarly you might find certain environments or comments distracting when trying to concentrate on the body of your document.

With AUCTeX’s folding functionality you can collapse those items and replace them by a fixed string, the content of one of their arguments, or a mixture of both. If you want to make the original text visible again in order to view or edit it, move point sideways onto the placeholder (also called display string) or left-click with the mouse pointer on it. (The latter is currently only supported on Emacs.) The macro or environment will unfold automatically, stay open as long as point is inside of it and collapse again once you move point out of it. (Note that folding of environments currently does not work in every AUCTeX mode.)

In order to use this feature, you have to activate TeX-fold-mode which will activate the auto-reveal feature and the necessary commands to hide and show macros and environments. You can activate the mode in a certain buffer by typing the command M-x TeX-fold-mode RET or using the keyboard shortcut C-c C-o C-f. If you want to use it every time you edit a LaTeX document, add it to a hook:

(add-hook 'LaTeX-mode-hook (lambda ()
(TeX-fold-mode 1)))

If it should be activated in all AUCTeX modes, use TeX-mode-hook instead of LaTeX-mode-hook.

Once the mode is active there are several commands available to hide and show macros, environments and comments...

关于emacs - Emacs 中 LaTeX 的代码折叠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2642205/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com