且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Emacs中LaTeX的代码折叠

更新时间:2023-11-13 16:34:16

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

AUCTeX does folding: http://www.gnu.org/software/auctex/manual/auctex.html#Folding


对于像TeX和LaTeX这样的标记语言,一个受欢迎的投诉是有太多的在源文本中混乱,而且不能很好地关注内容。有一些宏,你只对他们封闭的内容感兴趣,像字体说明符,其中内容可能已被字体锁定的特殊方式字体化。或者在实际编辑它时想要看到的内容,例如脚注或引用。同样地,您可能会发现某些环境或意见分散注意力集中在文档的正文。

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.

使用AUCTeX的折叠功能,您可以折叠这些项目,并将其替换为固定的字符串,他们的一个参数的内容,或两者的混合。如果要使原始文本再次可见,以便查看或编辑它,请将其侧向移动到占位符(也称为显示字符串)上,或者用鼠标指针左键单击。 (后者目前仅支持Emacs。)宏或环境将自动展开,只要点在其中,保持打开状态,并且一旦您移出指针就会再次崩溃。 (请注意,环境折叠目前在每种AUCTeX模式下都不起作用。)

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.)

为了使用此功能,您必须激活 TeX-折叠模式,这将激活自动显示功能和必要的命令来隐藏和显示宏和环境。您可以通过键入命令 Mx TeX-fold-mode RET 或使用键盘快捷键 Cc Co Cf $来激活某个缓冲区中的模式C $ C>。如果要在每次编辑LaTeX文档时使用它,请将其添加到挂钩中:

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)))

如果应该在所有AUCTeX模式下激活,请使用 TeX-mode-hook 而不是 LaTeX-mode-hook

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...