Navigate a TeX code using emacs

Are there useful navigation shortcuts in emacs when editing a TeX source? For example jump to the beginning/end of section, or similar thing for environment, etc.

C-v and M-v are too coarse, and I am looking for smarter navigation tips. Something in the spirit of C-M f and C-M b which jump over balanced braces.

-
There is the C-M-a and C-M-e keys which jump to beginning and end of current environment? But only by using AucTeX. –  zeroth Aug 7 '12 at 10:39
I use the jove (Jonathan's Own Version of Emacs) editor. While it is not intrinsically set up to support LaTeX, it is programmable with macros, key rebinding, etc. Here is a full manual: manuals.its.virginia.edu/unixdocs/u003a.jove.ref.html –  Steven B. Segletes Jun 25 at 2:24

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

-
@Michael: Thanks! And to Percusse... –  Brent.Longborough Aug 7 '12 at 12:21
AucTeX Reference Card link is broken –  CharlesHolbrow Jun 23 at 21:42
@CharlesHolbrow I've updated the answer, but unfortunately haven't been able to find a good replacement for the link. What I did find didn't have the details of the key bindings. –  Brent.Longborough Jun 24 at 20:04
@Thérèse Actually, I had the good sense to look on CTAN first :) Updated with the new link. –  Sean Allred Jun 24 at 20:29
@SeanAllred The new link might break when the next version of Auctex is released. Note that the source for the reference card, tex-ref.info, ships with auctex in the ./doc directory. The pdf is also available from manual and reference card link on the auctex project pages: gnu.org/software/auctex/download-for-unix.html –  Tyler Jun 24 at 20:38

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)

-
It might seem like a lot of work, but once you get the hang of it you can make new commands within the minute. –  Dualinity Aug 7 '12 at 11:14

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

-

I've recently discovered that imenu works well in TeX buffers. Paired with Helm completion, it's a force to be reckoned with. It isn't as heavy-weight as RefTeX for documents that wouldn't otherwise benefit from RefTeX's functionality.

For a sample, try out this document:

\documentclass{article}
\begin{document}
\section{hello}
\subsection{this}
\subsubsection{is}
\subsubsection{a}
\paragraph{simple}
\subparagraph{test}
\subsubsection{of}