[Tex/LaTex] Are there any coding style guidelines for LaTeX

best practicessourcecode

I have been using LaTeX for a long time now, but still all my document files look a bit messy. Now I want to get rid of this bad habit and get some order into my code.

That is why I am wondering whether there are any coding style guidelines for LaTeX. Not necessarily anything official. It could for example make recommendations on how to format your code with respect to:

  • Setting comments in the text/preamble
  • Whether to highlight sections/subsections etc. by some comments
  • How to indent environements
  • How to organize your preamble to make it readable
  • etc.

If nothing as such exists (yet), it would be great if you could just post how you do it if you think your code looks rather nice.

Best Answer

There was a talk at TUG'11 exactly about this: Didier Verna, Toward LaTeX coding standards:

enter image description here

The paper is available for TUG members only till the end of the year, but the video is available for all. Take a look: Didier has many interesting thoughts to offer. You might be also interested in Chris Rowley's talk at TUG'09. And please consider joining TUG: this gives you an immediate access to TUGboat papers and many other benefits (see http://tug.org/join.html)

Related Question