# Source Code Indentation

I was wondering if it is possible to indent the code like in most programming languages as shown below:

``````\part
\chapter
\section
\subsection    etc.
``````

This would make the source code much more readable. So is it possible? If yes how?

-
possibly related question: tex.stackexchange.com/questions/26102/… –  doncherry Dec 17 '11 at 16:31
Whilst I think this is a bad idea in general, it could be useful for table or figure environments, and especially for TikZ. –  qubyte Dec 17 '11 at 17:59
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Jubobs Jan 28 at 1:02

Yes, it is possible. Spaces at the begin of source lines is always ignored by TeX. However, I disagree that it is more readable for a normal document. Having several paragraphs of a, say `\subsubsection` indented by many spaces is not really readable to me. Instead I normally add certain separation lines before the sectioning commands, like 80-120x `%`. You can use two or more of them for higher sectioning commands. Multiple chapters and parts should be not in one source file anyway, IMHO, but instead split over several files which are then included in the main document using `\include` or `\input`.