Next: Labels and References, Previous: Introduction, Up: Top [Contents][Index]

## 2 Table of Contents

Pressing the keys `C-c =` pops up a buffer showing the table of contents of the document. By default, this `*toc*` buffer shows only the sections of a document. Using the `l` and `i` keys you can display all labels and index entries defined in the document as well.

With the cursor in any of the lines denoting a location in the document, simple key strokes will display the corresponding part in another window, jump to that location, or perform other actions.

Here is a list of special commands in the `*toc*` buffer. A summary of this information is always available by pressing `?`.

`General`
`?`

  Display a summary of commands.

`0-9, -`

  Prefix argument.

`Moving around`
`n`

  Goto next entry in the table of contents.

`p`

  Goto previous entry in the table of contents.

`C-c C-n`

  Goto next section heading. Useful when many labels and index entries separate section headings.

`C-c C-p`

  Goto previous section heading.

`N z`

  Jump to section N, using the prefix arg. For example, `3 z` jumps to section 3.

`Access to document locations`
`SPC`

  Show the corresponding location in another window. This command does not select that other window.

`TAB`

  Goto the location in another window.

`RET`

  Go to the location and hide the `*toc*` buffer. This will restore the window configuration before `reftex-toc` (`C-c =`) was called.

`mouse-2`

  Clicking with mouse button 2 on a line has the same effect as `RET`. See also variable `reftex-highlight-selection`, Options - Fontification.

`f`

  Toggle follow mode. When follow mode is active, the other window will always show the location corresponding to the line at point in the `*toc*` buffer. This is similar to pressing `SPC` after each cursor motion. The default for this flag can be set with the variable `reftex-toc-follow-mode`. Note that only context in files already visited is shown. RefTeX will not visit a file just for follow mode. See, however, the variable `reftex-revisit-to-follow`.

`.`

  Show calling point in another window. This is the point from where `reftex-toc` was last called.

`Promotion and Demotion`
`<`

  Promote the current section. This will convert `\section` to `\chapter`, `\subsection` to `\section` etc. If there is an active region, all sections in the region will be promoted, including the one at point. To avoid mistakes, RefTeX requires a fresh document scan before executing this command; if necessary, it will automatically do this scan and ask the user to repeat the promotion command.

`>`

  Demote the current section. This is the opposite of promotion. It will convert `\chapter` to `\section` etc. If there is an active region, all sections in the region will be demoted, including the one at point.

`M-%`

  Rename the label at point. While generally not recommended, this can be useful when a package like `fancyref` is used where the label prefix determines the wording of a reference. After a promotion/demotion it may be necessary to change a few labels from ‘`sec:xyz`’ to ‘`cha:xyz`’ or vice versa. This command can be used to do this; it launches a query replace to rename the definition and all references of a label.

`Exiting`
`q`

  Hide the `*toc*` buffer, return to the position where `reftex-toc` was last called.

`k`

  Kill the `*toc*` buffer, return to the position where `reftex-toc` was last called.

`C-c >`

  Switch to the `*Index*` buffer of this document. With prefix ‘`2`’, restrict the index to the section at point in the `*toc*` buffer.

`Controlling what gets displayed`
`t`

  Change the maximum level of toc entries displayed in the `*toc*` buffer. Without prefix arg, all levels will be included. With prefix arg (e.g., `3 t`), ignore all toc entries with level greater than arg (3 in this case). Chapters are level 1, sections are level 2. The mode line ‘`T<>`’ indicator shows the current value. The default depth can be configured with the variable `reftex-toc-max-level`.

`F`

  Toggle the display of the file borders of a multifile document in the `*toc*` buffer. The default for this flag can be set with the variable `reftex-toc-include-file-boundaries`.

`l`

  Toggle the display of labels in the `*toc*` buffer. The default for this flag can be set with the variable `reftex-toc-include-labels`. When called with a prefix argument, RefTeX will prompt for a label type and include only labels of the selected type in the `*toc*` buffer. The mode line ‘`L<>`’ indicator shows which labels are included.

`i`

  Toggle the display of index entries in the `*toc*` buffer. The default for this flag can be set with the variable `reftex-toc-include-index-entries`. When called with a prefix argument, RefTeX will prompt for a specific index and include only entries in the selected index in the `*toc*` buffer. The mode line ‘`I<>`’ indicator shows which index is used.

`c`

  Toggle the display of label and index context in the `*toc*` buffer. The default for this flag can be set with the variable `reftex-toc-include-context`.

`Updating the buffer`
`g`

  Rebuild the `*toc*` buffer. This does not rescan the document.

`r`

  Reparse the LaTeX document and rebuild the `*toc*` buffer. When `reftex-enable-partial-scans` is non-`nil`, rescan only the file this location is defined in, not the entire document.

`C-u r`

  Reparse the entire LaTeX document and rebuild the `*toc*` buffer.

`x`

  Switch to the `*toc*` buffer of an external document. When the current document is using the `xr` package (see LaTeX xr Package), RefTeX will switch to one of the external documents.

`Automatic recentering`
`d`

  Toggle the display of a dedicated frame displaying just the `*toc*` buffer. Follow mode and visiting locations will not work that frame, but automatic recentering will make this frame always show your current editing location in the document (see below).

`a`

  Toggle the automatic recentering of the `*toc*` buffer. When this option is on, moving around in the document will cause the `*toc*` to always highlight the current section. By default, this option is active while the dedicated `*TOC*` frame exists. See also the variable `reftex-auto-recenter-toc`.

In order to define additional commands for the `*toc*` buffer, the keymap `reftex-toc-map` may be used.

If you call `reftex-toc` while the `*toc*` buffer already exists, the cursor will immediately jump to the right place, i.e., the section from which `reftex-toc` was called will be highlighted. The command `C-c -` (`reftex-toc-recenter`) will only redisplay the `*toc*` buffer and highlight the correct line without actually selecting the `*toc*` window. This can be useful to quickly find out where in the document you currently are. You can also automate this by asking RefTeX to keep track of your current editing position in the TOC. The TOC window will then be updated whenever you stop typing for more than `reftex-idle-time` seconds. By default this works only with the dedicated `*TOC*` frame. But you can also force automatic recentering of the TOC window on the current frame with

    (setq reftex-auto-recenter-toc t)

The section macros recognized by RefTeX are all LaTeX section macros (from `\part` to `\subsubparagraph`) and the commands `\addchap` and `\addsec` from the KOMA-Script classes. Additional macros can be configured with the variable `reftex-section-levels`. It is also possible to add certain LaTeX environments to the table of contents. This is probably only useful for theorem-like environments. See Defining Label Environments, for an example.

Next: Labels and References, Previous: Introduction, Up: Top [Contents][Index]