I am new at LaTeX and I am asking myself at the moment if there is a convention how to indent the source code.

For example:

\item erstes Stichwort
\item zweites Stichwort

The code above is a bit confusing.

So, for now I want to indent the two \item-lines. But how? With tabs, with spaces.. If yes, with how many spaces?

Is there a convention in LaTeX?

Thanks for your help!

  • 4
    There is no convention and from a technical point of view, it doesn't matter if you are using spaces or tabs. Do as you like.
    – Johannes_B
    May 21, 2018 at 7:54
  • 4
    there is no general convention and latex will ignore any tabs and spaces at beginning of line so it is up to you, some editors will auto-indent to a particular style or there is the latexindent commandline utility that you can use. personally I don't indent \item May 21, 2018 at 7:55
  • 2
    We had tex.stackexchange.com/q/354696/35864 before (which was closed). A few examples of indentation are in tex.stackexchange.com/q/26102/35864. Also related: tex.stackexchange.com/q/325505/35864. But really there is no standard. Do whatever makes the code readable to you. TeX ignores spaces/tabs at the beginning of a line, so you can do what you want. A blank line is like a new paragraph, so you need to be careful if you want to use those. I normally indent by two spaces, but I don't indent everywhere.
    – moewe
    May 21, 2018 at 7:57
  • Maybe this as a reference, too: tex.stackexchange.com/questions/167714/… May 21, 2018 at 10:37
  • 2
    Fortunately, there are not conventions. Many people indent the items, but in nested list by long items, finally you obtain a tangle of text, code a long spaces and unnecessary item breaks. Then no indentation at all is the clear format (IMHO of course). Other times very short item are even better in a single line (e.g.,\item Yes \Item No \item Maybe )
    – Fran
    May 21, 2018 at 19:37

1 Answer 1


You are right. Code is much more readable if properly indented. How to find out about a missing } as long as a line ends with ...p{1cm}}}!

How much you indent an \item isn't important.

If you use new lines to get readable code like


bear in mind that you might get unwanted white space.

Indention should be made by the editor »automagically«. Emacs in AUCTeX mode is very good doing that for you, but you can't learn everything at the same time. Start with LaTeX, later get a real editor (=Emacs).

It has been said in the comments that TeX ignores spaces at the start of a line.

Yes, but there is (at least) one exception from this rule: The package »comment« (you get the documentation probably with texdoc comment on the command line) provides an environment called comment and that does not work with leading spaces before \begin{comment}.

Not the answer you're looking for? Browse other questions tagged or ask your own question.