Navigate a TeX code using emacs

If you use AucTeX, with outline minor mode turned on, you get a series of useful key-bindings, including (C- = Ctrl-):

C-c @ C-n   Move to next heading (at any level)
C-c @ C-p   Move to previous heading (at any level)
C-c @ C-f   Move Forward to next heading at the same level
C-c @ C-b   Move Backward to previous heading at the same level

(A quick look at the AucTeX Reference Card will get you started.)


The answer lies in Emacs for navigating around a document.

For specific needs in Tex, I would make a macro.

For next section (which is same as ending of previous section):

    F3          % start recording
    C-s section % search forward for any type of "section"; \sec for specifically \section
    RETURN      % stop there
    F4          % end recording  
    % you could choose to search for \begin{, or for anything.
    Reusing the F4 will replay the macro, so you can test it.

Save it for later use " C-x C-k n " then giving the name, and using Return.

M-x insert-kbd-macro RETURN the-given-name RETURN will paste the code into your document.

If you then put the code into your .emacs file, followed by

    (eval-after-load 'latex
                     '(define-key LaTeX-mode-map (kbd "C-c C-z") 'the-given-name))

The keybind will only load when you enter latex mode. (First restart/reload the .emacs) This way C-c C-z would go to the next section (or other specified search)


C-c = in reftex. But reftex is much more than that

How to use reftex http://jblevins.org/log/large

Keybindins at Section 1.2 RefTeX in a Nutshell
https://www.gnu.org/software/auctex/manual/reftex.html#SEC1

Tags:

Emacs

Editors