1

When I'm editing a org-mode file, the structure of mine is like this(you may need configuration in init.el):

* A section
  This is the content of the section
  #+BEGIN_SRC lang
    code here
  #+END_SRC
  ** A subsection
     This is the content of the subsection
* Another section
  This is the content of another section

But when when I'm editing a tex file using auctex, the structure of the tex file is this after I indented the whole buffer:

\documentclass{article}

\begin{document}

\section{A section}
This is the content of the section.

\begin{verbatim}
some verbatim text
\end{verbatim}

\subsection{A subsection}
This is the content of the subsection

\section{Another section}
This is the content of another section

\end{document}

It is not easy to view the whole structure, I know I can use C-c = to view the toc, but how can I make it like org-mode such as:

\documentclass{article}

\begin{document}

  \section{A section}
    This is the content of the section.

    \begin{verbatim}
      some verbatim text
    \end{verbatim}

    \subsection{A subsection}
      This is the content of the subsection

  \section{Another section}
    This is the content of another section

\end{document}

So, how can I indent the tex file (just using TAB and ENTER keys when editing it or indent the whole buffer using TAB or indent command)?

I mean, every block (section, subsection, EVERY \begin{}...\end{} pair no matter what is inside the {}) should be a part and should be in its place related to its parent? And the indent-level should be configurable.

How can do I do that? I googled a lot and found nothing useful.

  • 1
    You do not want to indent every environment, especially verbatim-like ones. Most of the other ones are already indented as you like. Indenting the "document" environment doesn't make much sense, it's the fundamental one and text in included files won't be indented in the same way. Personally, I don't find indenting sections' body very helpful, font locking of the section title is more useful to me. I'm not sure what you ask is easy to accomplish (I have to see the code), but it's easier if you use sectioning environments – giordano Sep 14 '16 at 11:21
  • If you really wanted to to do this, you would need to edit/replace the LaTeX-indent-line function to tell it about your own indentation rules. That would probably be a lot of work, and would likely break a lot of other things. Instead, let me suggest that you try using outline-minor-mode within your latex buffers so that you can fold up the rest of the buffer besides the part you are actually working on. – Dan Sep 14 '16 at 21:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.