11

I'm new to AUCTeX and I wonder:

is it possible to fold entire sections or subsections of a LaTeX document for a better overview, so that they are only represented by their headline (kind of a tree view of the document)?

I would expected that being done by the "folding" features, but I could not manage to hide a whole section, but folding seems to hide only some selected elements of the source code.

Is there a feature like what I'm searching in AUCTeX?

percusse
  • 157,807
  • Could you post a MWE including the part of the source code that fails to fold completely? – Ricardo Dec 30 '12 at 16:40
  • 3
    With TeX-fold-mode and outline-minor-mode you should be able to fold the document in a manageable way (via the outline menu and corresponding bound keys). However, without a minimal example, we can only take guesses at what might be wrong. – Ricardo Dec 30 '12 at 16:46
  • @Ricardo: thanks! in the meantime I found out, that "folding" is not what I need, but this outline-minor-mode... the problem is: I can not enter the commands, because Aquamacs does not recognize the "@" sign: http://superuser.com/questions/525988/aquamacs-2-4-how-to-input-in-commands-for-outline-mode – MostlyHarmless Dec 30 '12 at 17:05
  • TeX-fold-mode is here to fold environments and macros (for example replacing \lambda with a unicode lambda or hide a long proof). outline-minor-mode is what you need, as you stated, but you shouldn't have to set the heading levels yourself, auctex should take care of that for you. – T. Verron Dec 30 '12 at 17:08
  • @T.Verron: thanks. So which commands could I use to jump e. g. to the next section heading on the same level as the current one? As stated in the linked question in the superuser-forum, I can not enter any commands containing "@" at the moment. – MostlyHarmless Dec 30 '12 at 17:10
  • Hm, I misunderstood what you meant with the @ thing, sorry. Found a potential solution, but it was too long for a simple comment. – T. Verron Dec 30 '12 at 17:21
  • You might want to consider using Org-mode for drafting and then export to LaTeX as you finalize your document. Handling outlines in Org-mode is easier and more efficient than using outline-minor-mode, for instance sections are foldable via Tab by default. See e.g. the heading Implementation in http://tex.stackexchange.com/a/22443/5701 – N.N. Dec 30 '12 at 18:30
  • @N.N. thanks for your comment! That sounds interesting, however, as I already have a very complex and long LaTeX document with formulas, many custom commands and many graphics/tables, I'm not sure if I even could convert it to org-mode easily and I don't think that I want it... – MostlyHarmless Dec 30 '12 at 18:35

2 Answers2

19

Scrolling is not my hobby...

For easy navigation use the table of contents inside Emacs. Just type C-c = and Emacs displays it. You can navigate incredibly fast.


From the comments, if it does not 'work out of the box,' you can use

M-x reftex-mode

to turn it on for the current buffer or, to make the change permanent, add the following to your .emacs:

; If you use AUCTeX (you probably do; if you don't, you probably should):
(add-hook 'LaTeX-mode-hook 'turn-on-reftex)
(setq reftex-plug-into-AUCTeX t)

; If you do not:
(add-hook 'latex-mode-hook 'turn-on-reftex)
Sean Allred
  • 27,421
Keks Dose
  • 30,892
  • 2
    You might want to mention that this requires RefTeX and how to enable it. – N.N. Dec 30 '12 at 19:09
  • thanks a lot, Keksdose!! This is really cool - thanks! Not an answer to the question, but a really great "workaround" :-) @N.N. in my case (Aquamacs 2.4 on OS 10.6.8) it worked out of the box. :-) – MostlyHarmless Dec 30 '12 at 19:36
11

TeX-fold-mode is here to fold environments and macros (for example replacing \lambda with a Unicode lambda or hiding a long proof). outline-minor-mode is what you need, as you stated in the comments, but you shouldn't have to set the heading levels yourself, AUCTeX should take care of that for you.

If the key mapping is a problem to you, the easiest way to change it is to change the prefix-key for outline-mode.

This solution is described on EmacsWiki, where I found the following code snippet (to be added in your .emacs:

(add-hook 'outline-minor-mode-hook
            (lambda () (local-set-key "\C-c\C-@"
                                      outline-mode-prefix-map)))))

The above snippet will actually do nothing in AUCTeX, but you can replace \C-c\C-@ with any sequence of keys you like. The shortcuts will then use that key sequence instead : for example, to move to the next visible heading, you'll use <your key sequence> C-n.

You'll find on EmacsWiki many other options to change the keybindings, as well as suggestions for the choice of keys (but you'll probably need to figure out what key to use yourself, due to the many keybindings needed by AUCTeX).

N.N.
  • 36,163
T. Verron
  • 13,552