Rahul Sharma (Editor)

Indentation (typesetting)

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

In the written form of many languages, an indentation is an empty space at the beginning of a line to signal the start of a new paragraph. Many computer languages have adopted this technique to designate "paragraphs" or other logical blocks in the program.

Contents

For example, the following lines are indented, using between one and six spaces:

 This paragraph is indented by 1 space.

   This paragraph is indented by 3 spaces.

      This paragraph is indented by 6 spaces.

In computer programming, the neologisms outdent and unindent are used to describe the reversal of the indentation process, realigning text with the page margin (or with previous, lesser, levels of indentation).

In right-to-left languages (e.g. Hebrew and Arabic), indentation is used just the same, but from the right margin of the paper, where the line begins.

Indentation in typesetting

There are three main types of indentation, illustrated below in relation to borders representing the page dimensions.

A first-line indentation indents the first line.
A first-line indentation of 2 em:
A hanging indentation indents the rest of the text while leaving the first line in place.
A hanging indentation of 2 em:
A block indentation indents the entire block of text.
A block indentation of 2 em on the left: Indentation from both sides is commonly used for block quotations, here shown with 2 em on the left and right (which may amount to more on the right for certain lines, depending on word wrapping, if the text does not have justified alignment): A justified-text example of a block quotation that has been block-indented from both sides by 3 em:

Indentation in programming

In computer programming languages, indentation is used to format program source code to improve readability. Indentation is generally only of use to programmers; compilers and interpreters rarely care how much whitespace is present in between programming statements. However, certain programming languages rely on the use of indentation to demarcate programming structure, often using a variation of the off-side rule. The Haskell, Occam, Python, and Ya programming languages rely on indentation in this way.

Debates over where to indent, whether to use spaces or tabs, and how many spaces to use are often hotly debated among programmers, leading some to classify indentation as akin to a religious war. In 2006 a third method of indentation was proposed, called elastic tabstops.

In addition to general indentation of statements, different bracket indentation styles are commonly used.

References

Indentation (typesetting) Wikipedia