# How to use code folding with Aquamacs?

I would like to use code folding with Aquamacs but I don't find any reference to do it. I would like to fold the figure and the paragraph. I've already tried all the combination listed here. Can anybody give my a practical example to fold this code? And a \section.

\begin{figure}[h!]
\centering
\includegraphics[width=0.5\textwidth]{fiocco}
\caption{A running dog}
\label{fig:fiocc}
\end{figure}


I've used C-c,C-o,C-r but it doesn't work....

• To fold the figure environment use C-C C-o C-e with point inside that environment. Oct 6, 2013 at 16:25
• @giordano this works, so I can undo this using C-c C-o p. I can fold automatically all the figure? For the section seems I have to do something else...Thanks a lot!
– G M
Oct 6, 2013 at 16:35

You have to customize TeX-fold-env-spec-list (LaTeX-fold-env-spec-list is more appropriate but the result is just the same if you use only LaTeX and not plain TeX). In your init file add this code

(add-to-list 'TeX-fold-env-spec-list '("[figure]" ("figure")))


Then with C-c C-o C-b (M-xTeX-fold-bufferRET) all figure environments in the current buffer will be folded at once. To fold only figure environments in the current paragraph use C-c C-o C-p (M-xTeX-fold-paragraphRET).

The folding of paragraphs is done using the outline minor mode (see also the Outlining the Document section in AUCTeX manual). You can activate it with M-xoutline-minor-modeRET and then use the Outline menu.

• Thank a lot, can I do the same with \section and \subsection?
– G M
Oct 7, 2013 at 16:27
• @GM see the updated answer. Oct 7, 2013 at 16:59
• @GM did you see the updated answer? Is it complete now? Oct 11, 2013 at 19:47
• Yes thanks a lot I've voted up you, usually I wait always a week to accept answer, don't worry I will soon do it!
– G M
Oct 12, 2013 at 7:27