2010-04-15 9 views
13

Có chế độ nhỏ Emacs (hay đoạn mã elisp) cho phép bạn ẩn/hiển thị có chọn lọc môi trường trong khi ở chế độ LaTeX không? Ví dụ, tôi muốn di chuyển đến đầu của một khối dài \begin{figure}, nhấn một phím tắt, và có nội dung của môi trường con số đó ẩn khỏi xem. Tương tự như vậy với \begin{proof} và như vậy, và lý tưởng ngay cả với \subsection s.Mã gấp cho LaTeX ở Emacs

Điều này có khả thi không? Tôi vừa thử hs-minor-mode, allout-modeoutline-minor-mode, nhưng hầu hết trong số họ không nhận ra môi trường của LaTeX, ví dụ: hs-minor-mode không thành công với "scan error: unbalanced parentheses". Tôi không muốn phải nhập dấu gấp rõ ràng như {{{như trong folding-mode.

[Lý tưởng nhất là nó sẽ là tuyệt vời nếu gấp là persistent, nhưng tôi thấy rằng câu hỏi mà không có câu trả lời chấp nhận được nêu ra.]

Trả lời

13

AUCTeX không gấp: 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...

+0

Thật vậy, nhờ ! Bây giờ tôi cảm thấy như một thằng ngốc. :-) – ShreevatsaR

+4

Bạn cũng có thể sử dụng các lệnh phác thảo, như M-x hide-body và M-x show-subtree. Ngoài ra kiểm tra RefTeX, trong đó có một tính năng điều hướng ToC. –